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