1 package example.symphony;
\r
5 * @author Andrea Esposito <and1989@gmail.com>
\r
7 public class Tuple<X, Y> {
\r
15 public Tuple(X x, Y y) {
\r
21 public boolean equals(Object obj) {
\r
23 if (obj instanceof Tuple) {
\r
24 Tuple tuple = (Tuple) obj;
\r
26 // (x != null && tuple.x != null) ==> (x==tuple.x || x.equals(tuple.x))
\r
27 // x == null <==> tuple.x == null
\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
32 return equalsX && equalsY;
\r
39 public int hashCode() {
\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