Mercurial > projects > dwt2
comparison org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/value/ValueDiff.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, 2007 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 *******************************************************************************/ | |
11 | |
12 package org.eclipse.core.databinding.observable.value; | |
13 | |
14 import org.eclipse.core.databinding.observable.Diffs; | |
15 | |
16 /** | |
17 * @since 1.0 | |
18 * | |
19 */ | |
20 public abstract class ValueDiff { | |
21 /** | |
22 * Creates a value diff. | |
23 */ | |
24 public this() { | |
25 } | |
26 | |
27 /** | |
28 * @return the old value | |
29 */ | |
30 public abstract Object getOldValue(); | |
31 | |
32 /** | |
33 * @return the new value | |
34 */ | |
35 public abstract Object getNewValue(); | |
36 | |
37 public override equals_t opEquals(Object obj) { | |
38 if ( null !is cast(ValueDiff)obj ) { | |
39 ValueDiff val = cast(ValueDiff) obj; | |
40 | |
41 return Diffs.equals(val.getNewValue(), getNewValue()) | |
42 && Diffs.equals(val.getOldValue(), getOldValue()); | |
43 | |
44 } | |
45 return false; | |
46 } | |
47 | |
48 public override hash_t toHash() { | |
49 final int prime = 31; | |
50 int result = 1; | |
51 Object nv = getNewValue(); | |
52 Object ov = getOldValue(); | |
53 result = prime * result + ((nv is null) ? 0 : nv.hashCode()); | |
54 result = prime * result + ((ov is null) ? 0 : ov.hashCode()); | |
55 return result; | |
56 } | |
57 | |
58 /** | |
59 * @see java.lang.Object#toString() | |
60 */ | |
61 public String toString() { | |
62 StringBuffer buffer = new StringBuffer(); | |
63 buffer | |
64 .append(getClass().getName()) | |
65 .append("{oldValue [") //$NON-NLS-1$ | |
66 .append(getOldValue() !is null ? getOldValue().toString() : "null") //$NON-NLS-1$ | |
67 .append("], newValue [") //$NON-NLS-1$ | |
68 .append(getNewValue() !is null ? getNewValue().toString() : "null") //$NON-NLS-1$ | |
69 .append("]}"); //$NON-NLS-1$ | |
70 | |
71 return buffer.toString(); | |
72 } | |
73 } |