-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathVCImplication.java
More file actions
82 lines (68 loc) · 2.1 KB
/
VCImplication.java
File metadata and controls
82 lines (68 loc) · 2.1 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
77
78
79
80
81
82
package liquidjava.processor;
import liquidjava.rj_language.Predicate;
import liquidjava.utils.Utils;
import spoon.reflect.reference.CtTypeReference;
/**
* @author cgamboa
*/
public class VCImplication {
String name;
CtTypeReference<?> type;
Predicate refinement;
VCImplication next;
public VCImplication(String name, CtTypeReference<?> type, Predicate ref) {
this.name = name;
this.type = type;
this.refinement = ref;
}
public VCImplication(Predicate ref) {
this.refinement = ref;
}
public void setNext(VCImplication c) {
next = c;
}
public String getName() {
return name;
}
public CtTypeReference<?> getType() {
return type;
}
public Predicate getRefinement() {
return refinement;
}
public void setRefinement(Predicate refinement) {
this.refinement = refinement;
}
public VCImplication getNext() {
return next;
}
public String toString() {
if (name != null && type != null) {
String qualType = type.getQualifiedName();
String simpleType = qualType.contains(".") ? Utils.getSimpleName(qualType) : qualType;
return String.format("%-20s %s %s", "∀" + name + ":" + simpleType + ",", refinement.toString(),
next != null ? " => \n" + next : "");
} else
return String.format("%-20s %s", "", refinement.toString());
}
public Predicate toConjunctions() {
Predicate c = new Predicate();
if (name == null && type == null && next == null)
return c;
c = auxConjunction(c);
return c;
}
private Predicate auxConjunction(Predicate c) {
Predicate t = Predicate.createConjunction(c, refinement);
if (next == null)
return t;
t = next.auxConjunction(t);
return t;
}
public VCImplication clone() {
VCImplication vc = new VCImplication(this.name, this.type, this.refinement.clone());
if (this.next != null)
vc.next = this.next.clone();
return vc;
}
}