5309bac34eac53ea149a4dc893d2ddde16bbf70b
[IRC.git] / Robust / src / Analysis / SSJava / FlowEdge.java
1 package Analysis.SSJava;
2
3 import IR.Descriptor;
4
5 public class FlowEdge {
6
7   private FlowNode src;
8   private FlowNode dst;
9
10   // indicates that which tuple in the graph initiates this edge
11   private NTuple<Descriptor> initTuple;
12
13   // indicates that which tuple in the graph is the end of this edge
14   private NTuple<Descriptor> endTuple;
15
16   public FlowEdge(FlowNode src, FlowNode dst, NTuple<Descriptor> initTuple,
17       NTuple<Descriptor> endTuple) {
18     this.src = src;
19     this.dst = dst;
20     this.initTuple = initTuple;
21     this.endTuple = endTuple;
22   }
23
24   public String toString() {
25     return "Edge(" + initTuple + "/" + endTuple + "):: " + src + " to " + dst;
26   }
27
28   public FlowNode getSrc() {
29     return src;
30   }
31
32   public void setSrc(FlowNode src) {
33     this.src = src;
34   }
35
36   public FlowNode getDst() {
37     return dst;
38   }
39
40   public void setDst(FlowNode dst) {
41     this.dst = dst;
42   }
43
44   public NTuple<Descriptor> getInitTuple() {
45     return initTuple;
46   }
47
48   public void setInitTuple(NTuple<Descriptor> initTuple) {
49     this.initTuple = initTuple;
50   }
51
52   public int hashCode() {
53     return src.hashCode() + dst.hashCode() + initTuple.hashCode() + endTuple.hashCode();
54   }
55
56   public NTuple<Descriptor> getEndTuple() {
57     return endTuple;
58   }
59
60   public boolean equals(Object obj) {
61
62     if (obj instanceof FlowEdge) {
63       FlowEdge in = (FlowEdge) obj;
64       if (src.equals(in.getSrc()) && dst.equals(in.getDst()) && initTuple.equals(in.getInitTuple())
65           && endTuple.equals(in.getEndTuple())) {
66         return true;
67       }
68     }
69
70     return false;
71   }
72
73 }