-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPair.java
More file actions
59 lines (51 loc) · 1023 Bytes
/
Pair.java
File metadata and controls
59 lines (51 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package gir2java;
/**
* The usual Pair class. Immutable by default, but can be subclassed to make a mutable version.
* @author relek
*
* @param <TA>
* @param <TB>
*/
public class Pair<TA, TB> {
protected TA a;
protected TB b;
public Pair(TA a, TB b) {
this.a = a;
this.b = b;
}
TA getA() {
return a;
}
TB getB() {
return b;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((a == null) ? 0 : a.hashCode());
result = prime * result + ((b == null) ? 0 : b.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Pair other = (Pair) obj;
if (a == null) {
if (other.a != null)
return false;
} else if (!a.equals(other.a))
return false;
if (b == null) {
if (other.b != null)
return false;
} else if (!b.equals(other.b))
return false;
return true;
}
}