-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDependencySet.java
More file actions
66 lines (52 loc) · 1.76 KB
/
DependencySet.java
File metadata and controls
66 lines (52 loc) · 1.76 KB
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
61
62
63
64
65
66
package eu.europa.ted.efx.model.dependencies;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* A set of field and node identifiers collected during a parse tree walk.
* Used as a stack frame in the dependency extraction process.
*/
public class DependencySet {
private final Set<String> fieldIds = new LinkedHashSet<>();
private final Set<String> nodeIds = new LinkedHashSet<>();
private final Set<String> codelistNames = new LinkedHashSet<>();
public void addField(final String fieldId) {
this.fieldIds.add(fieldId);
}
public void addNode(final String nodeId) {
this.nodeIds.add(nodeId);
}
public void addCodelist(final String codelistName) {
this.codelistNames.add(codelistName);
}
public void removeField(final String fieldId) {
this.fieldIds.remove(fieldId);
}
public void removeNode(final String nodeId) {
this.nodeIds.remove(nodeId);
}
public void addAll(final DependencySet other) {
this.fieldIds.addAll(other.fieldIds);
this.nodeIds.addAll(other.nodeIds);
this.codelistNames.addAll(other.codelistNames);
}
public Set<String> getFieldIds() {
return Collections.unmodifiableSet(this.fieldIds);
}
public Set<String> getNodeIds() {
return Collections.unmodifiableSet(this.nodeIds);
}
public Set<String> getCodelistNames() {
return Collections.unmodifiableSet(this.codelistNames);
}
public boolean isEmpty() {
return this.fieldIds.isEmpty() && this.nodeIds.isEmpty() && this.codelistNames.isEmpty();
}
public Set<String> allIds() {
final Set<String> result = new LinkedHashSet<>();
result.addAll(this.fieldIds);
result.addAll(this.nodeIds);
result.addAll(this.codelistNames);
return Collections.unmodifiableSet(result);
}
}