Backport COLLECTIONS-228 to 3.2.2.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/COLLECTIONS_3_2_X@1713175 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9876243087
commit
3afb3cb345
|
@ -30,6 +30,10 @@
|
|||
"SetUniqueList.addAll(int, Collection)" now correctly add the collection at the
|
||||
provided index.
|
||||
</action>
|
||||
<action issue="COLLECTIONS-228" dev="scolebourne" type="fix">
|
||||
"MultiValueMap#put(Object, Object)" and "MultiValueMap#putAll(Object, Collection)"
|
||||
now correctly return if the map has changed by this operation.
|
||||
</action>
|
||||
<action issue="COLLECTIONS-219" dev="scolebourne" type="fix" due-to="Tom Leccese">
|
||||
"CollectionUtils#removeAll" wrongly called "ListUtils#retainAll".
|
||||
</action>
|
||||
|
@ -78,10 +82,6 @@
|
|||
"Flat3Map#remove(Object)" will now return the correct value mapped to the removed key
|
||||
if the size of the map is less or equal 3.
|
||||
</action>
|
||||
<action issue="COLLECTIONS-228" dev="scolebourne" type="fix">
|
||||
"MultiValueMap#put(Object, Object)" and "MultiValueMap#putAll(Object, Collection)"
|
||||
now correctly return if the map has changed by this operation.
|
||||
</action>
|
||||
<action issue="COLLECTIONS-217" dev="scolebourne" type="fix" due-to="Matt Bishop">
|
||||
Calling "setValue(Object)" on any Entry returned by a "Flat3Map" will now
|
||||
correctly set the value for the current entry.
|
||||
|
|
|
@ -211,7 +211,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||
if (coll.size() > 0) {
|
||||
// only add if non-zero size to maintain class state
|
||||
getMap().put(key, coll);
|
||||
result = false;
|
||||
result = true; // map definitely changed
|
||||
}
|
||||
} else {
|
||||
result = coll.add(value);
|
||||
|
@ -308,19 +308,20 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||
if (values == null || values.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
boolean result = false;
|
||||
Collection coll = getCollection(key);
|
||||
if (coll == null) {
|
||||
coll = createCollection(values.size());
|
||||
boolean result = coll.addAll(values);
|
||||
coll.addAll(values);
|
||||
if (coll.size() > 0) {
|
||||
// only add if non-zero size to maintain class state
|
||||
getMap().put(key, coll);
|
||||
result = false;
|
||||
result = true; // map definitely changed
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return coll.addAll(values);
|
||||
result = coll.addAll(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
@ -250,6 +251,16 @@ public class TestMultiValueMap extends TestCase {
|
|||
assertEquals(false, map.containsValue("A", "AB"));
|
||||
}
|
||||
|
||||
public void testPut_ReturnValue() {
|
||||
MultiValueMap test = new MultiValueMap();
|
||||
assertNotNull(test.put("key", "object1"));
|
||||
assertNotNull(test.put("key", "object2"));
|
||||
|
||||
List coll = Arrays.asList(new String[]{"uno", "un"});
|
||||
assertTrue(test.putAll("key", coll));
|
||||
assertFalse(test.putAll("key", new ArrayList()));
|
||||
}
|
||||
|
||||
public void testPutAll_Map1() {
|
||||
MultiMap original = new MultiValueMap();
|
||||
original.put("key", "object1");
|
||||
|
|
Loading…
Reference in New Issue