90eafa4
From 066f654cd6a1b9d3bfd54565af1d618dada2deb4 Mon Sep 17 00:00:00 2001
90eafa4
From: Michael Simacek <msimacek@redhat.com>
90eafa4
Date: Tue, 17 Nov 2015 01:02:55 +0100
90eafa4
Subject: [PATCH] Port to Java 8
90eafa4
90eafa4
---
90eafa4
 src/java/org/apache/commons/collections/MultiHashMap.java      |  8 ++++----
90eafa4
 src/java/org/apache/commons/collections/MultiMap.java          |  4 ++--
90eafa4
 src/java/org/apache/commons/collections/map/MultiKeyMap.java   |  8 +++++---
90eafa4
 src/java/org/apache/commons/collections/map/MultiValueMap.java |  8 ++++----
90eafa4
 src/test/org/apache/commons/collections/TestMultiHashMap.java  | 10 +++++-----
90eafa4
 .../org/apache/commons/collections/map/TestMultiKeyMap.java    |  4 ++--
90eafa4
 6 files changed, 22 insertions(+), 20 deletions(-)
90eafa4
Timothy St. Clair 451ad3c
diff --git a/src/java/org/apache/commons/collections/MultiHashMap.java b/src/java/org/apache/commons/collections/MultiHashMap.java
90eafa4
index 7fec9af..bcb4a11 100644
Timothy St. Clair 451ad3c
--- a/src/java/org/apache/commons/collections/MultiHashMap.java
Timothy St. Clair 451ad3c
+++ b/src/java/org/apache/commons/collections/MultiHashMap.java
Timothy St. Clair 451ad3c
@@ -331,21 +331,21 @@ public class MultiHashMap extends HashMap implements MultiMap {
Timothy St. Clair 451ad3c
      * @param item  the value to remove
Timothy St. Clair 451ad3c
      * @return the value removed (which was passed in), null if nothing removed
Timothy St. Clair 451ad3c
      */
Timothy St. Clair 451ad3c
-    public Object remove(Object key, Object item) {
Timothy St. Clair 451ad3c
+    public boolean remove(Object key, Object item) {
Timothy St. Clair 451ad3c
         Collection valuesForKey = getCollection(key);
Timothy St. Clair 451ad3c
         if (valuesForKey == null) {
Timothy St. Clair 451ad3c
-            return null;
Timothy St. Clair 451ad3c
+            return false;
Timothy St. Clair 451ad3c
         }
Timothy St. Clair 451ad3c
         boolean removed = valuesForKey.remove(item);
Timothy St. Clair 451ad3c
         if (removed == false) {
Timothy St. Clair 451ad3c
-            return null;
Timothy St. Clair 451ad3c
+            return false;
Timothy St. Clair 451ad3c
         }
Timothy St. Clair 451ad3c
         // remove the list if it is now empty
Timothy St. Clair 451ad3c
         // (saves space, and allows equals to work)
Timothy St. Clair 451ad3c
         if (valuesForKey.isEmpty()){
Timothy St. Clair 451ad3c
             remove(key);
Timothy St. Clair 451ad3c
         }
Timothy St. Clair 451ad3c
-        return item;
Timothy St. Clair 451ad3c
+        return true;
Timothy St. Clair 451ad3c
     }
Timothy St. Clair 451ad3c
 
Timothy St. Clair 451ad3c
     /**
Timothy St. Clair 451ad3c
diff --git a/src/java/org/apache/commons/collections/MultiMap.java b/src/java/org/apache/commons/collections/MultiMap.java
90eafa4
index be9455b..4d9cc7d 100644
Timothy St. Clair 451ad3c
--- a/src/java/org/apache/commons/collections/MultiMap.java
Timothy St. Clair 451ad3c
+++ b/src/java/org/apache/commons/collections/MultiMap.java
Timothy St. Clair 451ad3c
@@ -66,7 +66,7 @@ public interface MultiMap extends Map {
Timothy St. Clair 451ad3c
      * @throws ClassCastException if the key or value is of an invalid type
Timothy St. Clair 451ad3c
      * @throws NullPointerException if the key or value is null and null is invalid
Timothy St. Clair 451ad3c
      */
Timothy St. Clair 451ad3c
-    public Object remove(Object key, Object item);
Timothy St. Clair 451ad3c
+    public boolean remove(Object key, Object item);
Timothy St. Clair 451ad3c
 
Timothy St. Clair 451ad3c
     //-----------------------------------------------------------------------
Timothy St. Clair 451ad3c
     /**
Timothy St. Clair 451ad3c
@@ -144,7 +144,7 @@ public interface MultiMap extends Map {
Timothy St. Clair 451ad3c
      * @throws ClassCastException if the key is of an invalid type
Timothy St. Clair 451ad3c
      * @throws NullPointerException if the key is null and null keys are invalid
Timothy St. Clair 451ad3c
      */
Timothy St. Clair 451ad3c
-    Object remove(Object key);
Timothy St. Clair 451ad3c
+    //boolean remove(Object key);
Timothy St. Clair 451ad3c
 
Timothy St. Clair 451ad3c
     /**
Timothy St. Clair 451ad3c
      * Gets a collection containing all the values in the map.
Timothy St. Clair 451ad3c
diff --git a/src/java/org/apache/commons/collections/map/MultiKeyMap.java b/src/java/org/apache/commons/collections/map/MultiKeyMap.java
90eafa4
index 9e3e02d..969d11e 100644
Timothy St. Clair 451ad3c
--- a/src/java/org/apache/commons/collections/map/MultiKeyMap.java
Timothy St. Clair 451ad3c
+++ b/src/java/org/apache/commons/collections/map/MultiKeyMap.java
Timothy St. Clair 451ad3c
@@ -197,7 +197,7 @@ public class MultiKeyMap
Timothy St. Clair 451ad3c
      * @param key2  the second key
Timothy St. Clair 451ad3c
      * @return the value mapped to the removed key, null if key not in map
Timothy St. Clair 451ad3c
      */
Timothy St. Clair 451ad3c
-    public Object remove(Object key1, Object key2) {
Timothy St. Clair 451ad3c
+    public boolean remove(Object key1, Object key2) {
Timothy St. Clair 451ad3c
         int hashCode = hash(key1, key2);
Timothy St. Clair 451ad3c
         int index = map.hashIndex(hashCode, map.data.length);
Timothy St. Clair 451ad3c
         AbstractHashedMap.HashEntry entry = map.data[index];
Timothy St. Clair 451ad3c
@@ -206,12 +206,14 @@ public class MultiKeyMap
Timothy St. Clair 451ad3c
             if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) {
Timothy St. Clair 451ad3c
                 Object oldValue = entry.getValue();
Timothy St. Clair 451ad3c
                 map.removeMapping(entry, index, previous);
Timothy St. Clair 451ad3c
-                return oldValue;
Timothy St. Clair 451ad3c
+                //return oldValue;
Timothy St. Clair 451ad3c
+                return true;
Timothy St. Clair 451ad3c
             }
Timothy St. Clair 451ad3c
             previous = entry;
Timothy St. Clair 451ad3c
             entry = entry.next;
Timothy St. Clair 451ad3c
         }
Timothy St. Clair 451ad3c
-        return null;
Timothy St. Clair 451ad3c
+        //return null;
Timothy St. Clair 451ad3c
+        return false;
Timothy St. Clair 451ad3c
     }
Timothy St. Clair 451ad3c
 
Timothy St. Clair 451ad3c
     /**
Timothy St. Clair 451ad3c
diff --git a/src/java/org/apache/commons/collections/map/MultiValueMap.java b/src/java/org/apache/commons/collections/map/MultiValueMap.java
90eafa4
index f44999b..79938dc 100644
Timothy St. Clair 451ad3c
--- a/src/java/org/apache/commons/collections/map/MultiValueMap.java
Timothy St. Clair 451ad3c
+++ b/src/java/org/apache/commons/collections/map/MultiValueMap.java
Timothy St. Clair 451ad3c
@@ -153,19 +153,19 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
Timothy St. Clair 451ad3c
      * @param value the value to remove
Timothy St. Clair 451ad3c
      * @return the value removed (which was passed in), null if nothing removed
Timothy St. Clair 451ad3c
      */
Timothy St. Clair 451ad3c
-    public Object remove(Object key, Object value) {
Timothy St. Clair 451ad3c
+    public boolean remove(Object key, Object value) {
Timothy St. Clair 451ad3c
         Collection valuesForKey = getCollection(key);
Timothy St. Clair 451ad3c
         if (valuesForKey == null) {
Timothy St. Clair 451ad3c
-            return null;
Timothy St. Clair 451ad3c
+            return false;
Timothy St. Clair 451ad3c
         }
Timothy St. Clair 451ad3c
         boolean removed = valuesForKey.remove(value);
Timothy St. Clair 451ad3c
         if (removed == false) {
Timothy St. Clair 451ad3c
-            return null;
Timothy St. Clair 451ad3c
+            return false;
Timothy St. Clair 451ad3c
         }
Timothy St. Clair 451ad3c
         if (valuesForKey.isEmpty()) {
Timothy St. Clair 451ad3c
             remove(key);
Timothy St. Clair 451ad3c
         }
Timothy St. Clair 451ad3c
-        return value;
Timothy St. Clair 451ad3c
+        return true;
Timothy St. Clair 451ad3c
     }
Timothy St. Clair 451ad3c
 
Timothy St. Clair 451ad3c
     /**
Timothy St. Clair 451ad3c
diff --git a/src/test/org/apache/commons/collections/TestMultiHashMap.java b/src/test/org/apache/commons/collections/TestMultiHashMap.java
90eafa4
index eca833a..f47c6f9 100644
Timothy St. Clair 451ad3c
--- a/src/test/org/apache/commons/collections/TestMultiHashMap.java
Timothy St. Clair 451ad3c
+++ b/src/test/org/apache/commons/collections/TestMultiHashMap.java
Timothy St. Clair 451ad3c
@@ -464,11 +464,11 @@ public class TestMultiHashMap extends AbstractTestMap {
Timothy St. Clair 451ad3c
         map.put("A", "AA");
Timothy St. Clair 451ad3c
         map.put("A", "AB");
Timothy St. Clair 451ad3c
         map.put("A", "AC");
Timothy St. Clair 451ad3c
-        assertEquals(null, map.remove("C", "CA"));
Timothy St. Clair 451ad3c
-        assertEquals(null, map.remove("A", "AD"));
Timothy St. Clair 451ad3c
-        assertEquals("AC", map.remove("A", "AC"));
Timothy St. Clair 451ad3c
-        assertEquals("AB", map.remove("A", "AB"));
Timothy St. Clair 451ad3c
-        assertEquals("AA", map.remove("A", "AA"));
Timothy St. Clair 451ad3c
+        assertEquals(false, map.remove("C", "CA"));
Timothy St. Clair 451ad3c
+        assertEquals(false, map.remove("A", "AD"));
Timothy St. Clair 451ad3c
+        assertEquals(true, map.remove("A", "AC"));
Timothy St. Clair 451ad3c
+        assertEquals(true, map.remove("A", "AB"));
Timothy St. Clair 451ad3c
+        assertEquals(true, map.remove("A", "AA"));
Timothy St. Clair 451ad3c
         assertEquals(new MultiHashMap(), map);
Timothy St. Clair 451ad3c
     }
Timothy St. Clair 451ad3c
 
Timothy St. Clair 451ad3c
diff --git a/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java b/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
90eafa4
index b1ee3d0..66fcade 100644
Timothy St. Clair 451ad3c
--- a/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
Timothy St. Clair 451ad3c
+++ b/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
Timothy St. Clair 451ad3c
@@ -315,10 +315,10 @@ public class TestMultiKeyMap extends AbstractTestIterableMap {
Timothy St. Clair 451ad3c
             switch (key.size()) {
Timothy St. Clair 451ad3c
                 case 2:
Timothy St. Clair 451ad3c
                 assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1)));
Timothy St. Clair 451ad3c
-                assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1)));
Timothy St. Clair 451ad3c
+                assertEquals(true, multimap.remove(key.getKey(0), key.getKey(1)));
Timothy St. Clair 451ad3c
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1)));
Timothy St. Clair 451ad3c
                 assertEquals(size - 1, multimap.size());
Timothy St. Clair 451ad3c
-                assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1)));
Timothy St. Clair 451ad3c
+                assertEquals(false, multimap.remove(key.getKey(0), key.getKey(1)));
Timothy St. Clair 451ad3c
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1)));
Timothy St. Clair 451ad3c
                 break;
Timothy St. Clair 451ad3c
                 case 3:
90eafa4
-- 
90eafa4
2.5.0
90eafa4