--- /dev/null
+package example.symphony;\r
+\r
+/**\r
+ *\r
+ * @author Andrea Esposito <and1989@gmail.com>\r
+ */\r
+public class Tuple<X, Y> {\r
+\r
+ public X x;\r
+ public Y y;\r
+\r
+ public Tuple() {\r
+ }\r
+\r
+ public Tuple(X x, Y y) {\r
+ this.x = x;\r
+ this.y = y;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+\r
+ if (obj instanceof Tuple) {\r
+ Tuple tuple = (Tuple) obj;\r
+\r
+ // (x != null && tuple.x != null) ==> (x==tuple.x || x.equals(tuple.x))\r
+ // x == null <==> tuple.x == null\r
+\r
+ boolean equalsX = (x == null && tuple.x == null) || ((x != null && tuple.x != null) && (x == tuple.x || x.equals(tuple.x)));\r
+ boolean equalsY = (y == null && tuple.y == null) || ((y != null && tuple.y != null) && (y == tuple.y || y.equals(tuple.y)));\r
+\r
+ return equalsX && equalsY;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ int hash = 5;\r
+ hash = 89 * hash + (this.x != null ? this.x.hashCode() : 0);\r
+ hash = 89 * hash + (this.y != null ? this.y.hashCode() : 0);\r
+ return hash;\r
+ }\r
+}\r