Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Energy, onHostDestruction: ensured ptr existence
[simgrid.git] / contrib / psg / src / example / symphony / Tuple.java
1 package example.symphony;\r
2 \r
3 /**\r
4  *\r
5  * @author Andrea Esposito <and1989@gmail.com>\r
6  */\r
7 public class Tuple<X, Y> {\r
8 \r
9     public X x;\r
10     public Y y;\r
11 \r
12     public Tuple() {\r
13     }\r
14 \r
15     public Tuple(X x, Y y) {\r
16         this.x = x;\r
17         this.y = y;\r
18     }\r
19 \r
20     @Override\r
21     public boolean equals(Object obj) {\r
22 \r
23         if (obj instanceof Tuple) {\r
24             Tuple tuple = (Tuple) obj;\r
25 \r
26             // (x != null && tuple.x != null) ==> (x==tuple.x || x.equals(tuple.x))\r
27             // x == null <==> tuple.x == null\r
28 \r
29             boolean equalsX = (x == null && tuple.x == null) || ((x != null && tuple.x != null) && (x == tuple.x || x.equals(tuple.x)));\r
30             boolean equalsY = (y == null && tuple.y == null) || ((y != null && tuple.y != null) && (y == tuple.y || y.equals(tuple.y)));\r
31 \r
32             return equalsX && equalsY;\r
33         }\r
34 \r
35         return false;\r
36     }\r
37 \r
38     @Override\r
39     public int hashCode() {\r
40         int hash = 5;\r
41         hash = 89 * hash + (this.x != null ? this.x.hashCode() : 0);\r
42         hash = 89 * hash + (this.y != null ? this.y.hashCode() : 0);\r
43         return hash;\r
44     }\r
45 }\r