-
Notifications
You must be signed in to change notification settings - Fork 188
/
AxiomIdentifierDefinition.java
58 lines (44 loc) · 1.77 KB
/
AxiomIdentifierDefinition.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
package com.evolveum.axiom.api.schema;
import java.util.Collection;
import java.util.Set;
import com.evolveum.axiom.api.AxiomName;
import com.evolveum.axiom.api.AxiomValue;
import com.google.common.collect.ImmutableSet;
public interface AxiomIdentifierDefinition extends AxiomValue<AxiomIdentifierDefinition> {
@Override
default AxiomIdentifierDefinition get() {
return this;
}
Collection<AxiomItemDefinition> components();
Scope scope();
AxiomName space();
enum Scope {
GLOBAL,
PARENT,
LOCAL
}
static AxiomIdentifierDefinition global(AxiomName name, AxiomItemDefinition... components) {
return new AxiomIdentifierDefinitionImpl(ImmutableSet.copyOf(components), name, Scope.GLOBAL);
}
static AxiomIdentifierDefinition local(AxiomName name, AxiomItemDefinition... components) {
return new AxiomIdentifierDefinitionImpl(ImmutableSet.copyOf(components), name, Scope.LOCAL);
}
static Scope scope(String scope) {
if(Scope.GLOBAL.name().equalsIgnoreCase(scope)) {
return Scope.GLOBAL;
}
if(Scope.PARENT.name().equalsIgnoreCase(scope)) {
return Scope.PARENT;
}
if(Scope.LOCAL.name().equalsIgnoreCase(scope)) {
return Scope.LOCAL;
}
throw new IllegalArgumentException("Unknown scope " + scope);
}
static AxiomIdentifierDefinition from(AxiomName space, Scope scope, Set<AxiomItemDefinition> members) {
return new AxiomIdentifierDefinitionImpl(ImmutableSet.copyOf(members), space, scope);
}
static AxiomIdentifierDefinition parent(AxiomName name, AxiomItemDefinition... components) {
return new AxiomIdentifierDefinitionImpl(ImmutableSet.copyOf(components), name, Scope.PARENT);
}
}