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