1 package de.fhdw.wtf.persistence.utils;
2
3
4
5
6
7
8
9 public class Tuple<X, Y> {
10
11 private final X first;
12
13 private final Y second;
14
15
16
17
18
19 public X getFirst() {
20 return this.first;
21 }
22
23
24
25
26
27 public Y getSecond() {
28 return this.second;
29 }
30
31
32
33
34
35
36
37 public Tuple(final X first, final Y second) {
38 super();
39 this.first = first;
40 this.second = second;
41 }
42
43 @SuppressWarnings("rawtypes")
44 @Override
45 public boolean equals(final java.lang.Object obj) {
46 if (obj instanceof Tuple) {
47 return this.customEquals((Tuple) obj);
48 }
49 return false;
50 }
51
52 private boolean customEquals(@SuppressWarnings("rawtypes") final Tuple obj) {
53 return this.getFirst().equals(obj.getFirst()) && this.getSecond().equals(obj.getSecond());
54 }
55
56 @Override
57 public String toString() {
58 return "(" + this.getFirst() + "," + this.getSecond() + ")";
59 }
60
61 @Override
62 public int hashCode() {
63 return this.getFirst().hashCode() ^ this.getSecond().hashCode();
64 }
65
66 }