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