forked from typetools/checker-framework-inference
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathVertex.java
More file actions
76 lines (61 loc) · 1.62 KB
/
Copy pathVertex.java
File metadata and controls
76 lines (61 loc) · 1.62 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 checkers.inference.solver.constraintgraph;
import java.util.HashSet;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import checkers.inference.model.ConstantSlot;
import checkers.inference.model.Slot;
/** Vertex represents a slot. Two vertices are same if they have same slot id. */
public class Vertex {
private Set<Edge> edges;
private Slot slot;
private int id;
private AnnotationMirror value;
protected Vertex(Slot slot) {
this.edges = new HashSet<Edge>();
this.slot = slot;
this.id = slot.getId();
if (slot instanceof ConstantSlot) {
ConstantSlot cs = (ConstantSlot) slot;
this.value = cs.getValue();
} else {
this.value = null;
}
}
protected boolean isConstant() {
return (this.slot instanceof ConstantSlot);
}
protected void addEdge(Edge edge) {
if (!edges.contains(edge)) {
edges.add(edge);
}
}
public Slot getSlot() {
return this.slot;
}
protected int getId() {
return this.id;
}
protected Set<Edge> getEdges() {
return this.edges;
}
public AnnotationMirror getValue() {
return this.value;
}
@Override
public boolean equals(Object o) {
if (o instanceof Vertex) {
Vertex vertex = (Vertex) o;
if (vertex.id == this.id) {
return true;
} else {
return false;
}
} else {
return false;
}
}
@Override
public int hashCode() {
return id;
}
}