You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2013/11/17 18:10:33 UTC
svn commit: r1542763 - in /commons/proper/collections/trunk: ./ src/changes/
src/main/java/org/apache/commons/collections4/
src/main/java/org/apache/commons/collections4/map/ src/site/xdoc/
src/test/java/org/apache/commons/collections4/map/
Author: tn
Date: Sun Nov 17 17:10:33 2013
New Revision: 1542763
URL: http://svn.apache.org/r1542763
Log:
[COLLECTIONS-500] Renamed MultiMap.remove(K, V) to boolean removeMapping(K, V).
Modified:
commons/proper/collections/trunk/RELEASE-NOTES.txt
commons/proper/collections/trunk/src/changes/changes.xml
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MultiMap.java
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java
commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java
Modified: commons/proper/collections/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/RELEASE-NOTES.txt?rev=1542763&r1=1542762&r2=1542763&view=diff
==============================================================================
--- commons/proper/collections/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/collections/trunk/RELEASE-NOTES.txt Sun Nov 17 17:10:33 2013
@@ -47,6 +47,8 @@ Major changes since 3.2.1
Changes since 4.0-alpha1
------------------------
+ o [COLLECTIONS-500] Renamed "V MultiMap#remove(K, V)" to "boolean MultiMap#removeMapping(K, V)"
+ to avoid future conflicts with a default method of the Map interface in Java 8.
o [COLLECTIONS-499] Refactored the test framework for Bag implementations to extend from
"AbstractCollectionTest" by decorating the concrete Bag instance with
a CollectionBag or CollectionSortedBag.
@@ -171,6 +173,8 @@ New features
Changed classes / methods
-------------------------
+ o [COLLECTIONS-500] Renamed "V MultiMap#remove(K, V)" to "boolean MultiMap#removeMapping(K, V)"
+ to avoid future conflicts with a default method of the Map interface in Java 8.
o [COLLECTIONS-499] Refactored the test framework for Bag implementations to extend from
"AbstractCollectionTest" by decorating the concrete Bag instance with
a CollectionBag or CollectionSortedBag.
Modified: commons/proper/collections/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/changes/changes.xml?rev=1542763&r1=1542762&r2=1542763&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/changes/changes.xml (original)
+++ commons/proper/collections/trunk/src/changes/changes.xml Sun Nov 17 17:10:33 2013
@@ -21,7 +21,7 @@
</properties>
<body>
- <release version="4.0" date="2013-11-15" description="
+ <release version="4.0" date="2013-11-18" description="
This is a major release: It combines bug fixes, new features and
changes to existing features.
@@ -38,6 +38,10 @@ Commons Collections is Java 5.
Users are encouraged to upgrade to this version as, in addition to new
features, this release includes numerous bug fixes.
">
+ <action issue="COLLECTIONS-500" dev="tn" type="update">
+ Renamed "V MultiMap#remove(K, V)" to "boolean MultiMap#removeMapping(K, V)"
+ to avoid future conflicts with a default method of the Map interface in Java 8.
+ </action>
<action issue="COLLECTIONS-499" dev="tn" type="update">
Refactored the test framework for Bag implementations to extend from
"AbstractCollectionTest" by decorating the concrete Bag instance with
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MultiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MultiMap.java?rev=1542763&r1=1542762&r2=1542763&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MultiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MultiMap.java Sun Nov 17 17:10:33 2013
@@ -56,12 +56,13 @@ public interface MultiMap<K, V> extends
*
* @param key the key to remove from
* @param item the item to remove
- * @return the value removed (which was passed in), null if nothing removed
+ * @return {@code true} if the mapping was removed, {@code false} otherwise
* @throws UnsupportedOperationException if the map is unmodifiable
* @throws ClassCastException if the key or value is of an invalid type
* @throws NullPointerException if the key or value is null and null is invalid
+ * @since 4.0 (signature in previous releases: V remove(K, V))
*/
- public V remove(K key, V item);
+ boolean removeMapping(K key, V item);
//-----------------------------------------------------------------------
/**
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java?rev=1542763&r1=1542762&r2=1542763&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java Sun Nov 17 17:10:33 2013
@@ -205,22 +205,21 @@ public class MultiValueMap<K, V> extends
*
* @param key the key to remove from
* @param value the value to remove
- * @return the value removed (which was passed in), null if nothing removed
+ * @return {@code true} if the mapping was removed, {@code false} otherwise
*/
- @SuppressWarnings("unchecked")
- public V remove(final Object key, final Object value) {
+ public boolean removeMapping(final Object key, final Object value) {
final Collection<V> valuesForKey = getCollection(key);
if (valuesForKey == null) {
- return null;
+ return false;
}
final boolean removed = valuesForKey.remove(value);
if (removed == false) {
- return null;
+ return false;
}
if (valuesForKey.isEmpty()) {
remove(key);
}
- return (V) value;
+ return true;
}
/**
Modified: commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml?rev=1542763&r1=1542762&r2=1542763&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml (original)
+++ commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml Sun Nov 17 17:10:33 2013
@@ -156,6 +156,8 @@ have changed.
<center><h3>Changed classes / methods</h3></center>
<ul>
+<li>Renamed "V MultiMap#remove(K, V)" to "boolean MultiMap#removeMapping(K, V)"
+ to avoid future conflicts with a default method of the Map interface in Java 8.</li>
<li>Refactored the test framework for Bag implementations to extend from "AbstractCollectionTest" by decorating
the concrete Bag instance with a CollectionBag or CollectionSortedBag.</li>
<li>"UnmodifiableBoundedCollection" does now also implement the marker interface "Unmodifiable"
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java?rev=1542763&r1=1542762&r2=1542763&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java Sun Nov 17 17:10:33 2013
@@ -25,7 +25,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
-
import org.apache.commons.collections4.AbstractObjectTest;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.collections4.MultiMap;
@@ -179,7 +178,7 @@ public class MultiValueMapTest<K, V> ext
final MultiValueMap<K, V> one = new MultiValueMap<K, V>();
final Integer value = Integer.valueOf(1);
one.put((K) "One", value);
- one.remove("One", value);
+ one.removeMapping("One", value);
final MultiValueMap<K, V> two = new MultiValueMap<K, V>();
assertEquals(two, one);
@@ -207,7 +206,7 @@ public class MultiValueMapTest<K, V> ext
assertEquals(4, map.totalSize());
map.remove("A");
assertEquals(3, map.totalSize());
- map.remove("B", "BC");
+ map.removeMapping("B", "BC");
assertEquals(2, map.totalSize());
}
@@ -225,7 +224,7 @@ public class MultiValueMapTest<K, V> ext
assertEquals(2, map.size());
map.remove("A");
assertEquals(1, map.size());
- map.remove("B", "BC");
+ map.removeMapping("B", "BC");
assertEquals(1, map.size());
}
@@ -249,7 +248,7 @@ public class MultiValueMapTest<K, V> ext
map.remove("A");
assertEquals(0, map.size("A"));
assertEquals(3, map.size("B"));
- map.remove("B", "BC");
+ map.removeMapping("B", "BC");
assertEquals(0, map.size("A"));
assertEquals(2, map.size("B"));
}
@@ -377,11 +376,11 @@ public class MultiValueMapTest<K, V> ext
map.put((K) "A", "AA");
map.put((K) "A", "AB");
map.put((K) "A", "AC");
- assertEquals(null, map.remove("C", "CA"));
- assertEquals(null, map.remove("A", "AD"));
- assertEquals("AC", map.remove("A", "AC"));
- assertEquals("AB", map.remove("A", "AB"));
- assertEquals("AA", map.remove("A", "AA"));
+ assertEquals(false, map.removeMapping("C", "CA"));
+ assertEquals(false, map.removeMapping("A", "AD"));
+ assertEquals(true, map.removeMapping("A", "AC"));
+ assertEquals(true, map.removeMapping("A", "AB"));
+ assertEquals(true, map.removeMapping("A", "AA"));
assertEquals(new MultiValueMap<K, V>(), map);
}
@@ -397,7 +396,8 @@ public class MultiValueMapTest<K, V> ext
@Override
public Object makeObject() {
- final Map m = makeEmptyMap();
+ @SuppressWarnings("unchecked")
+ final Map<String, String> m = makeEmptyMap();
m.put("a", "1");
m.put("a", "1b");
m.put("b", "2");
@@ -407,6 +407,7 @@ public class MultiValueMapTest<K, V> ext
return m;
}
+ @SuppressWarnings("rawtypes")
private Map makeEmptyMap() {
return new MultiValueMap();
}