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