comparison org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/Pair.d @ 85:6be48cf9f95c

Work on databinding
author Frank Benoit <benoit@tionex.de>
date Sat, 18 Apr 2009 13:54:50 +0200
parents 0a55d2d5a946
children
comparison
equal deleted inserted replaced
84:fcf926c91ca4 85:6be48cf9f95c
32 * Construct a Pair(a, b) 32 * Construct a Pair(a, b)
33 * 33 *
34 * @param a a in the pair (a, b) 34 * @param a a in the pair (a, b)
35 * @param b b in the pair (a, b) 35 * @param b b in the pair (a, b)
36 */ 36 */
37 public this(String a, String b) {
38 this(stringcast(a), stringcast(b));
39 }
40 public this(Object a, String b) {
41 this(a, stringcast(b));
42 }
43 public this(String a, Object b) {
44 this(stringcast(a), b);
45 }
37 public this(Object a, Object b) { 46 public this(Object a, Object b) {
38 this.a = a; 47 this.a = a;
39 this.b = b; 48 this.b = b;
40 } 49 }
41 50
42 public int hashCode() { 51 public override hash_t toHash() {
43 final int prime = 31; 52 final int prime = 31;
44 int result = 1; 53 int result = 1;
45 result = prime * result + ((a is null) ? 0 : a.hashCode()); 54 result = prime * result + ((a is null) ? 0 : a.toHash());
46 result = prime * result + ((b is null) ? 0 : b.hashCode()); 55 result = prime * result + ((b is null) ? 0 : b.toHash());
47 return result; 56 return result;
48 } 57 }
49 58
50 public override bool opEquals(Object obj) { 59 public override equals_t opEquals(Object obj) {
51 if (this is obj) 60 if (this is obj)
52 return true; 61 return true;
53 if (obj is null) 62 if (obj is null)
54 return false; 63 return false;
55 if (getClass() !is obj.getClass()) 64 if (this.classinfo !is obj.classinfo)
56 return false; 65 return false;
57 Pair other = cast(Pair) obj; 66 Pair other = cast(Pair) obj;
58 if (a is null) { 67 if (a is null) {
59 if (other.a !is null) 68 if (other.a !is null)
60 return false; 69 return false;
61 } else if (!a.equals(other.a)) 70 } else if (!a.opEquals(other.a))
62 return false; 71 return false;
63 if (b is null) { 72 if (b is null) {
64 if (other.b !is null) 73 if (other.b !is null)
65 return false; 74 return false;
66 } else if (!b.equals(other.b)) 75 } else if (!b.opEquals(other.b))
67 return false; 76 return false;
68 return true; 77 return true;
69 } 78 }
70 79
71 } 80 }