1 package org.lsst.ccs.utilities.structs;
2
3 import java.io.Serializable;
4
5
6
7
8
9
10
11
12 public class Pair<K, V> implements Serializable {
13 public final K x;
14 public V y;
15
16 public Pair(K x, V y) {
17 this.x = x;
18 this.y = y;
19 }
20
21 public K getX() {
22 return x;
23 }
24
25 public V getY() {
26 return y;
27 }
28
29 public void setX(V v) {
30 this.y = v;
31 }
32
33 @Override
34 public String toString() {
35 return "[" + x + "," + y + "]";
36 }
37
38 @Override
39 public boolean equals(Object o) {
40 if (this == o) return true;
41 if (!(o instanceof Pair)) return false;
42
43 Pair pair = (Pair) o;
44
45 if (!x.equals(pair.x)) return false;
46 if (y != null ? !y.equals(pair.y) : pair.y != null) return false;
47
48 return true;
49 }
50
51 @Override
52 public int hashCode() {
53 int result = x.hashCode();
54 result = 31 * result + (y != null ? y.hashCode() : 0);
55 return result;
56 }
57 }