diff org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/Diffs.d @ 85:6be48cf9f95c

Work on databinding
author Frank Benoit <benoit@tionex.de>
date Sat, 18 Apr 2009 13:54:50 +0200
parents 0a55d2d5a946
children
line wrap: on
line diff
--- a/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/Diffs.d	Sat Apr 18 09:25:29 2009 +0200
+++ b/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/Diffs.d	Sat Apr 18 13:54:50 2009 +0200
@@ -22,7 +22,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Map.Entry;
 
 import org.eclipse.core.databinding.observable.list.ListDiff;
 import org.eclipse.core.databinding.observable.list.ListDiffEntry;
@@ -66,7 +65,7 @@
                 do {
                     done = true;
                     Object oldValue = oldList.get(index);
-                    if (oldValue is null ? newValue !is null : !oldValue.equals(newValue)) {
+                    if (oldValue is null ? newValue !is null : !oldValue.opEquals(newValue)) {
                         int oldIndexOfNewValue = listIndexOf(oldList, newValue, index);
                         if (oldIndexOfNewValue !is -1) {
                             int newIndexOfOldValue = listIndexOf(newList, oldValue, index);
@@ -122,7 +121,7 @@
         int size = list.size();
         for (int i=index; i<size;i++) {
             Object candidate = list.get(i);
-            if (candidateisnull ? objectisnull : candidate.equals(object)) {
+            if (candidate is null ? object is null : candidate.opEquals(object)) {
                 return i;
             }
         }
@@ -142,7 +141,7 @@
      */
     public static final bool equals(Object left, Object right) {
         return left is null ? right is null : ((right !is null) && left
-                .equals(right));
+                .opEquals(right));
     }
 
     /**
@@ -175,7 +174,7 @@
         final Map oldValues = new HashMap();
         final Map newValues = new HashMap();
         for (Iterator it = oldMap.entrySet().iterator(); it.hasNext();) {
-            Map.Entry oldEntry = cast(Entry) it.next();
+            Map.Entry oldEntry = cast(Map.Entry) it.next();
             Object oldKey = oldEntry.getKey();
             if (addedKeys.remove(oldKey)) {
                 // potentially changed key since it is in oldMap and newMap
@@ -223,6 +222,18 @@
      * @param newValue
      * @return a value diff
      */
+    public static ValueDiff createValueDiff(String oldValue,
+            Object newValue) {
+        return createValueDiff( stringcast(oldValue), newValue );
+    }
+    public static ValueDiff createValueDiff(Object oldValue,
+            String newValue) {
+        return createValueDiff( oldValue, stringcast(newValue) );
+    }
+    public static ValueDiff createValueDiff(String oldValue,
+            String newValue) {
+        return createValueDiff( stringcast(oldValue), stringcast(newValue) );
+    }
     public static ValueDiff createValueDiff(Object oldValue,
             Object newValue) {
         return new class(oldValue, newValue) ValueDiff {