1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package cz.cuni.amis.utils;
18
19
20
21
22
23
24
25 public class PairKey<FIRST, SECOND> {
26 private final FIRST first;
27 private final SECOND second;
28
29 public PairKey(FIRST first, SECOND second) {
30 this.first = first;
31 this.second = second;
32 }
33
34 public FIRST getFirst() {
35 return first;
36 }
37
38 public SECOND getSecond() {
39 return second;
40 }
41
42 @Override
43 public int hashCode() {
44 int hash = 7;
45 hash = 97 * hash + (this.first != null ? this.first.hashCode() : 0);
46 hash = 97 * hash + (this.second != null ? this.second.hashCode() : 0);
47 return hash;
48 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (obj == null) {
53 return false;
54 }
55 if (getClass() != obj.getClass()) {
56 return false;
57 }
58 final PairKey<FIRST, SECOND> other = (PairKey<FIRST, SECOND>) obj;
59 if (this.first != other.first && (this.first == null || !this.first.equals(other.first))) {
60 return false;
61 }
62 if (this.second != other.second && (this.second == null || !this.second.equals(other.second))) {
63 return false;
64 }
65 return true;
66 }
67
68
69 @Override
70 public String toString() {
71 return "Pair<" + first.toString() + ", " + second.toString();
72 }
73
74
75 }