-
Notifications
You must be signed in to change notification settings - Fork 188
/
AxiomIdentifierDefinition.java
56 lines (45 loc) · 1.81 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
/*
* Copyright (C) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.axiom.api.schema;
import java.util.Collection;
import java.util.Set;
import com.evolveum.axiom.api.AxiomStructuredValue;
import com.evolveum.axiom.api.AxiomName;
import com.evolveum.axiom.api.AxiomValue;
import com.google.common.collect.ImmutableSet;
public interface AxiomIdentifierDefinition extends AxiomStructuredValue {
Collection<AxiomName> components();
enum Scope {
GLOBAL,
PARENT,
LOCAL
}
static AxiomIdentifierDefinition global(AxiomName name, AxiomName... components) {
return new AxiomIdentifierDefinitionImpl(ImmutableSet.copyOf(components), name, Scope.GLOBAL);
}
static AxiomIdentifierDefinition local(AxiomName name, AxiomName... 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<AxiomName> members) {
return new AxiomIdentifierDefinitionImpl(ImmutableSet.copyOf(members), space, scope);
}
static AxiomIdentifierDefinition parent(AxiomName name, AxiomName... components) {
return new AxiomIdentifierDefinitionImpl(ImmutableSet.copyOf(components), name, Scope.PARENT);
}
}