You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2012/02/22 20:30:21 UTC

svn commit: r1292465 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java

Author: aadamchik
Date: Wed Feb 22 19:30:21 2012
New Revision: 1292465

URL: http://svn.apache.org/viewvc?rev=1292465&view=rev
Log:
CAY-1670 Non-blocking DataRowStore

JDK 1.5 compatibility. SimpleEntry only appears in java 6

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java?rev=1292465&r1=1292464&r2=1292465&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java Wed Feb 22 19:30:21 2012
@@ -1658,6 +1658,9 @@ public class ConcurrentLinkedHashMap<K, 
      * 
      * 
      * 
+     * 
+     * 
+     * 
      * {
      *     &#064;code
      *     ConcurrentMap&lt;Vertex, Set&lt;Edge&gt;&gt; graph = new Builder&lt;Vertex, Set&lt;Edge&gt;&gt;()
@@ -1824,4 +1827,54 @@ public class ConcurrentLinkedHashMap<K, 
             return map;
         }
     }
+
+    // a class similar to AbstractMap.SimpleEntry. Needed for JDK 5 compatibility. Java 6
+    // exposes it to external users.
+    static class SimpleEntry<K, V> implements Entry<K, V> {
+
+        K key;
+        V value;
+
+        public SimpleEntry(K key, V value) {
+            this.key = key;
+            this.value = value;
+        }
+
+        public SimpleEntry(Entry<K, V> e) {
+            this.key = e.getKey();
+            this.value = e.getValue();
+        }
+
+        public K getKey() {
+            return key;
+        }
+
+        public V getValue() {
+            return value;
+        }
+
+        public V setValue(V value) {
+            V oldValue = this.value;
+            this.value = value;
+            return oldValue;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof Entry))
+                return false;
+            Entry e = (Entry) o;
+            return eq(key, e.getKey()) && eq(value, e.getValue());
+        }
+
+        @Override
+        public int hashCode() {
+            return ((key == null) ? 0 : key.hashCode())
+                    ^ ((value == null) ? 0 : value.hashCode());
+        }
+
+        private static boolean eq(Object o1, Object o2) {
+            return (o1 == null ? o2 == null : o1.equals(o2));
+        }
+    }
 }