blob: 84cce2d55a0bb9e5ccb600028de1dd4b976fae1c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package cz.crcs.ectester.standalone.consts;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
public abstract class Ident {
Set<String> idents;
String name;
public Ident(String name, String... aliases) {
this.name = name;
this.idents = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
this.idents.add(name);
this.idents.addAll(Arrays.asList(aliases));
}
public String getName() {
return name;
}
public Set<String> getIdents() {
return Collections.unmodifiableSet(idents);
}
public boolean contains(String other) {
return name.equals(other) || idents.contains(other);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Ident)) {
return false;
}
Ident other = (Ident) obj;
return idents.equals(other.getIdents());
}
@Override
public int hashCode() {
return idents.hashCode() + 37;
}
@Override
public String toString() {
return "(" + String.join("|", idents) + ")";
}
}
|