1 public class DoubleKey<K extends Comparable<K>, J extends Comparable<J>>
2 implements Comparable<DoubleKey<K, J>> {
3
4 private K key1;
5 private J key2;
6
7 public DoubleKey(K key1, J key2) {
8 this.key1 = key1;
9 this.key2 = key2;
10 }
11
12 public K getFirstKey() {
13 return this.key1;
14 }
15
16 public J getSecondKey() {
17 return this.key2;
18 }
19
20 public int compareTo(DoubleKey<K, J> that) {
21
22 int cmp = this.getFirstKey().compareTo(that.getFirstKey());
23 if (cmp == 0)
24 cmp = this.getSecondKey().compareTo(that.getSecondKey());
25 return cmp;
26 }
27}