-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathNotConstraint.java
More file actions
76 lines (61 loc) · 2 KB
/
Copy pathNotConstraint.java
File metadata and controls
76 lines (61 loc) · 2 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
67
68
69
70
71
72
73
74
75
76
package de.vill.model.constraint;
import de.vill.model.building.VariableReference;
import de.vill.util.ConstantSymbols;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class NotConstraint extends Constraint {
private Constraint content;
public NotConstraint(Constraint content) {
this.content = content;
}
public Constraint getContent() {
return content;
}
@Override
public String toString(boolean withSubmodels, String currentAlias) {
StringBuilder result = new StringBuilder();
result.append(ConstantSymbols.NOT);
if (content instanceof VariableReference || content instanceof ParenthesisConstraint) {
result.append(content.toString(withSubmodels, currentAlias));
} else {
result.append(ConstantSymbols.PAREN_OPEN);
result.append(content.toString(withSubmodels, currentAlias));
result.append(ConstantSymbols.PAREN_CLOSE);
}
return result.toString();
}
@Override
public List<Constraint> getConstraintSubParts() {
return Arrays.asList(content);
}
@Override
public void replaceConstraintSubPart(Constraint oldSubConstraint, Constraint newSubConstraint) {
if (content == oldSubConstraint) {
content = newSubConstraint;
}
}
@Override
public Constraint clone() {
return new NotConstraint(content.clone());
}
@Override
public int hashCode(int level) {
return 31 * level + (content == null ? 0 : content.hashCode(1 + level));
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
NotConstraint other = (NotConstraint) obj;
return Objects.equals(content, other.content);
}
@Override
public List<VariableReference> getReferences() {
return content.getReferences();
}
}