Mercurial > projects > dwt2
comparison org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/IdentityWrapper.d @ 95:6208d4f6a277
Added trees for databinding.beans and observable
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 21 Apr 2009 10:55:51 +0200 |
parents | |
children | b74ac5dfcc06 |
comparison
equal
deleted
inserted
replaced
94:1d37a7813832 | 95:6208d4f6a277 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2006, 2008 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Daniel Kruegler - bug 137435 | |
11 *******************************************************************************/ | |
12 | |
13 package org.eclipse.core.internal.databinding.beans; | |
14 | |
15 /** | |
16 * Used for wrapping objects that define their own implementations of equals() | |
17 * and hashCode() when putting them in sets or hashmaps to ensure identity | |
18 * comparison. | |
19 * | |
20 * @since 1.0 | |
21 * | |
22 */ | |
23 public class IdentityWrapper { | |
24 final Object o; | |
25 | |
26 /** | |
27 * @param o | |
28 */ | |
29 public this(Object o) { | |
30 this.o = o; | |
31 } | |
32 | |
33 /** | |
34 * @return the unwrapped object | |
35 */ | |
36 public Object unwrap() { | |
37 return o; | |
38 } | |
39 | |
40 public override equals_t opEquals(Object obj) { | |
41 if (obj is null || obj.getClass() !is IdentityWrapper.class) { | |
42 return false; | |
43 } | |
44 return o is (cast(IdentityWrapper) obj).o; | |
45 } | |
46 | |
47 public override hash_t toHash() { | |
48 return System.identityHashCode(o); | |
49 } | |
50 } |