comparison org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/value/ValueDiff.d @ 78:0a55d2d5a946

Added file for databinding
author Frank Benoit <benoit@tionex.de>
date Tue, 14 Apr 2009 11:35:29 +0200
parents
children 6be48cf9f95c
comparison
equal deleted inserted replaced
76:f05e6e8b2f2d 78:0a55d2d5a946
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 module org.eclipse.core.databinding.observable.value.ValueDiff;
13
14 import java.lang.all;
15
16 import org.eclipse.core.databinding.observable.Diffs;
17
18 /**
19 * @since 1.0
20 *
21 */
22 public abstract class ValueDiff {
23 /**
24 * Creates a value diff.
25 */
26 public this() {
27 }
28
29 /**
30 * @return the old value
31 */
32 public abstract Object getOldValue();
33
34 /**
35 * @return the new value
36 */
37 public abstract Object getNewValue();
38
39 public override bool opEquals(Object obj) {
40 if ( null !is cast(ValueDiff)obj ) {
41 ValueDiff val = cast(ValueDiff) obj;
42
43 return Diffs.equals(val.getNewValue(), getNewValue())
44 && Diffs.equals(val.getOldValue(), getOldValue());
45
46 }
47 return false;
48 }
49
50 public int hashCode() {
51 final int prime = 31;
52 int result = 1;
53 Object nv = getNewValue();
54 Object ov = getOldValue();
55 result = prime * result + ((nv is null) ? 0 : nv.hashCode());
56 result = prime * result + ((ov is null) ? 0 : ov.hashCode());
57 return result;
58 }
59
60 /**
61 * @see java.lang.Object#toString()
62 */
63 public String toString() {
64 StringBuffer buffer = new StringBuffer();
65 buffer
66 .append(getClass().getName())
67 .append("{oldValue [") //$NON-NLS-1$
68 .append(getOldValue() !is null ? getOldValue().toString() : "null") //$NON-NLS-1$
69 .append("], newValue [") //$NON-NLS-1$
70 .append(getNewValue() !is null ? getNewValue().toString() : "null") //$NON-NLS-1$
71 .append("]}"); //$NON-NLS-1$
72
73 return buffer.toString();
74 }
75 }