-
Notifications
You must be signed in to change notification settings - Fork 188
/
IdentifierSpaceKey.java
60 lines (48 loc) · 1.54 KB
/
IdentifierSpaceKey.java
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
53
54
55
56
57
58
59
60
package com.evolveum.axiom.lang.api;
import java.util.Map;
import java.util.Map.Entry;
import com.evolveum.axiom.api.AxiomIdentifier;
import com.google.common.collect.ImmutableMap;
public class IdentifierSpaceKey {
private final Map<AxiomIdentifier, Object> components;
public IdentifierSpaceKey(Map<AxiomIdentifier, Object> components) {
this.components = ImmutableMap.copyOf(components);
}
public Map<AxiomIdentifier, Object> components() {
return components;
}
@Override
public int hashCode() {
return components().hashCode();
}
@Override
public boolean equals(Object obj) {
if(obj == this) {
return true;
}
if(obj instanceof IdentifierSpaceKey) {
return components().equals(((IdentifierSpaceKey) obj).components());
}
return false;
}
public static IdentifierSpaceKey from(Map<AxiomIdentifier, Object> build) {
return new IdentifierSpaceKey(build);
}
@Override
public String toString() {
StringBuilder b = new StringBuilder();
b.append("[");
boolean first = true;
for(Entry<AxiomIdentifier, Object> val : components().entrySet()) {
if(!first) {
b.append(",");
}
b.append(val.getKey()).append("=").append(val.getValue());
}
b.append("]");
return b.toString();
}
public static IdentifierSpaceKey of(AxiomIdentifier key, Object value) {
return from(ImmutableMap.of(key, value));
}
}