1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.model.visual.backward;
19
20 import java.io.Serializable;
21 import java.util.Date;
22
23 import com.thoughtworks.xstream.annotations.XStreamAlias;
24
25
26
27
28
29
30 @XStreamAlias("connection")
31 public class Connection implements Serializable {
32
33
34
35
36
37 private static final long serialVersionUID = -6068688858953611564L;
38
39 @XStreamAlias("sourceNode")
40 private Node sourceNode;
41
42 @XStreamAlias("targetNode")
43 private Node targetNode;
44
45 @XStreamAlias("startDate")
46 private Date startDate;
47
48
49
50
51 public Connection() {
52 }
53
54
55
56
57
58
59
60
61
62
63
64 public Connection(Node source, Node target, Date connectionStart) {
65 sourceNode = source;
66 targetNode = target;
67 startDate = connectionStart;
68 }
69
70 public Node getSourceNode() {
71 return sourceNode;
72 }
73
74 public void setSourceNode(Node sourceNode) {
75 this.sourceNode = sourceNode;
76 }
77
78 public Node getTargetNode() {
79 return targetNode;
80 }
81
82 public void setTargetNode(Node targetNode) {
83 this.targetNode = targetNode;
84 }
85
86 public Date getStartDate() {
87 return startDate;
88 }
89
90 public void setStartDate(Date startDate) {
91 this.startDate = startDate;
92 }
93
94
95
96
97
98
99
100 public void copyTo(Connection that) {
101
102 that.setStartDate(this.getStartDate());
103
104 }
105
106
107
108
109
110
111 @Override
112 public String toString() {
113
114 return sourceNode.getLabel() + "->" + targetNode.getLabel();
115 }
116
117
118
119
120
121
122 @Override
123 public boolean equals(Object obj) {
124 if (obj == this) {
125 return true;
126 }
127 if (!(obj instanceof Connection)) {
128 return false;
129 }
130 Connection that = (Connection)obj;
131
132 if (sourceNode == null) {
133 if (that.sourceNode != null) {
134 return false;
135 }
136 } else if (!sourceNode.equals(that.sourceNode)) {
137 return false;
138 }
139 if (targetNode == null) {
140 if (that.targetNode != null) {
141 return false;
142 }
143 } else if (!targetNode.equals(that.targetNode)) {
144 return false;
145 }
146 if (startDate == null) {
147 if (that.startDate != null) {
148 return false;
149 }
150 } else if (!startDate.equals(that.startDate)) {
151 return false;
152 }
153 return true;
154 }
155
156
157
158
159
160
161 @Override
162 public int hashCode() {
163 int result = 0;
164 int prime = 31;
165 result = sourceNode == null ? 0 : sourceNode.hashCode();
166 result = result * prime + (targetNode == null ? 0 : targetNode.hashCode());
167 result = result * prime + (startDate == null ? 0 : startDate.hashCode());
168 return result;
169 }
170
171 }