Last change
on this file was 1, checked in by Wouter Pasman, 6 years ago |
Initial import : Genius 9.0.0
|
File size:
899 bytes
|
Line | |
---|
1 | package negotiator.boaframework.offeringstrategy.anac2010.IAMhaggler2010;
|
---|
2 |
|
---|
3 | import java.io.Serializable;
|
---|
4 |
|
---|
5 | public class Pair<A, B> implements Serializable {
|
---|
6 |
|
---|
7 | public final A fst;
|
---|
8 | public final B snd;
|
---|
9 |
|
---|
10 | public Pair(A fst, B snd) {
|
---|
11 | this.fst = fst;
|
---|
12 | this.snd = snd;
|
---|
13 | }
|
---|
14 |
|
---|
15 | public String toString() {
|
---|
16 | return "Pair[" + fst + "," + snd + "]";
|
---|
17 | }
|
---|
18 |
|
---|
19 | private static boolean equals(Object x, Object y) {
|
---|
20 | return (x == null && y == null) || (x != null && x.equals(y));
|
---|
21 | }
|
---|
22 |
|
---|
23 | public boolean equals(Object other) {
|
---|
24 | return other instanceof Pair && equals(fst, ((Pair) other).fst) && equals(snd, ((Pair) other).snd);
|
---|
25 | }
|
---|
26 |
|
---|
27 | public int hashCode() {
|
---|
28 | if (fst == null)
|
---|
29 | return (snd == null) ? 0 : snd.hashCode() + 1;
|
---|
30 | else if (snd == null)
|
---|
31 | return fst.hashCode() + 2;
|
---|
32 | else
|
---|
33 | return fst.hashCode() * 17 + snd.hashCode();
|
---|
34 | }
|
---|
35 |
|
---|
36 | public static <A, B> Pair<A, B> of(A a, B b) {
|
---|
37 | return new Pair<A, B>(a, b);
|
---|
38 | }
|
---|
39 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.