Merge "Remove unnecessary getComparableKey from HashMapBinding"
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 7 Jan 2019 07:40:42 +0000 (07:40 +0000)
committerGerrit Code Review <gerrit2@simantics>
Mon, 7 Jan 2019 07:40:42 +0000 (07:40 +0000)
bundles/org.simantics.databoard/src/org/simantics/databoard/binding/factory/TroveBindingsProvider.java
bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/HashMapBinding.java

index 3eb17213be03a74d8a6ac00da6dde81ea48dc7d1..e8047450e331f59a1ce5900a7cd8c4d62eb43591 100644 (file)
@@ -75,7 +75,6 @@ public class TroveBindingsProvider implements BindingProvider {
                        
                        for (int i=0; i<len; i++) {
                                Object key = keys[i];
-                               key = getComparableKey(result, key);                    
                                Object value = values[i];
                                result.put(key, value);
                        }
@@ -93,7 +92,6 @@ public class TroveBindingsProvider implements BindingProvider {
                        
                        for (int i=0; i<len; i++) {
                                Object key = keys.get(i);
-                               key = getComparableKey(result, key);
                                Object value = values.get(i);
                                result.put(key, value);
                        }
index d8c63e34d15b8b72e03b9c216dc63877a06cd8fa..97eb55ac17d63a8bf93debb6188b6288a40425da 100644 (file)
@@ -68,7 +68,6 @@ public class HashMapBinding extends MapBinding {
                
                for (int i=0; i<len; i++) {
                        Object key = keys[i];
-                       key = getComparableKey(result, key);                    
                        Object value = values[i];
                        result.put(key, value);
                }
@@ -86,7 +85,6 @@ public class HashMapBinding extends MapBinding {
                
                for (int i=0; i<len; i++) {
                        Object key = keys.get(i);
-                       key = getComparableKey(result, key);
                        Object value = values.get(i);
                        result.put(key, value);
                }
@@ -225,27 +223,11 @@ public class HashMapBinding extends MapBinding {
                }
                return values;
        }
-
-       @SuppressWarnings("unchecked")
-       protected Object getComparableKey(Object map, Object key) {
-               // if (keyIsComparable) return key;
-               
-               Map<Object, Object> m = ((Map<Object, Object>)map);
-               Binding kb = getKeyBinding();
-               for (Object k : m.keySet())
-               {
-                       if (kb.equals(k, key))
-                               return k;
-               }
-               return key;
-       }
        
        @SuppressWarnings("unchecked")
        @Override
        public void put(Object map, Object key, Object value) {
                Map<Object, Object> m = ((Map<Object, Object>)map);
-               Object ck = getComparableKey(m, key);
-               m.remove(ck);
                m.put(key, value);
        }
 
@@ -254,8 +236,6 @@ public class HashMapBinding extends MapBinding {
        public <K, V> void putAll(Object map, Map<K, V>  src) throws BindingException {
                Map<K, V>  m = ((Map<K, V> )map);
                for (Entry<K, V>  e : (Set<Entry<K, V> >) src.entrySet()) {
-                       Object ck = getComparableKey(map, e.getKey());
-                       m.remove(ck);
                        m.put(e.getKey(), e.getValue());
                }
        }