1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.util;
20
21
22
23
24 public class Triple<A, B, C> {
25 private A first;
26 private B second;
27 private C third;
28
29 public Triple(A first, B second, C third) {
30 this.first = first;
31 this.second = second;
32 this.third = third;
33 }
34
35 public int hashCode() {
36 int hashFirst = (first != null ? first.hashCode() : 0);
37 int hashSecond = (second != null ? second.hashCode() : 0);
38 int hashThird = (third != null ? third.hashCode() : 0);
39
40 return (hashFirst >> 1) ^ hashSecond ^ (hashThird << 1);
41 }
42
43 public boolean equals(Object obj) {
44 if (!(obj instanceof Triple)) {
45 return false;
46 }
47
48 Triple<?, ?, ?> otherTriple = (Triple<?, ?, ?>) obj;
49
50 if (first != otherTriple.first && (first != null && !(first.equals(otherTriple.first))))
51 return false;
52 if (second != otherTriple.second && (second != null && !(second.equals(otherTriple.second))))
53 return false;
54 if (third != otherTriple.third && (third != null && !(third.equals(otherTriple.third))))
55 return false;
56
57 return true;
58 }
59
60 public String toString() {
61 return "(" + first + ", " + second + "," + third + " )";
62 }
63
64 public A getFirst() {
65 return first;
66 }
67
68 public void setFirst(A first) {
69 this.first = first;
70 }
71
72 public B getSecond() {
73 return second;
74 }
75
76 public void setSecond(B second) {
77 this.second = second;
78 }
79
80 public C getThird() {
81 return third;
82 }
83
84 public void setThird(C third) {
85 this.third = third;
86 }
87 }
88
89
90