[COLLECTIONS-474] Added sanity checks, javadoc clarification, changelog entry.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1496190 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2013-06-24 20:04:16 +00:00
parent 7df57879c9
commit fe63f95fbf
3 changed files with 13 additions and 5 deletions

View File

@ -192,6 +192,9 @@ Changed classes / methods
Fixed Bugs Fixed Bugs
---------- ----------
o [COLLECTIONS-474] ListOrderedMap#putAll(index, Object, Object) does not throw an exception anymore if the
map contains null values. Additionally added javadoc clarification on the supported bounds
for the index parameter. Thanks to Ning Chen.
o [COLLECTIONS-472] Improved performance of "AbstractMapBag#containsAll(Collection)" by returning immediately o [COLLECTIONS-472] Improved performance of "AbstractMapBag#containsAll(Collection)" by returning immediately
after a difference has been found. Thanks to Adrian Nistor. after a difference has been found. Thanks to Adrian Nistor.
o [COLLECTIONS-461] Added additional clarification to javadoc of interface "Put" wrt return type of o [COLLECTIONS-461] Added additional clarification to javadoc of interface "Put" wrt return type of

View File

@ -21,13 +21,10 @@
</properties> </properties>
<body> <body>
<release version="4.x" date="TBA" description="TBA"> <release version="4.0" date="TBA" description="Next release">
<action issue="COLLECTIONS-474" dev="sebb" type="fix" due-to="Ning Chen "> <action issue="COLLECTIONS-474" dev="sebb" type="fix" due-to="Ning Chen ">
Exception in ListOrderedMap#putAll if map contains null values. Exception in ListOrderedMap#putAll if map contains null values.
</action> </action>
</release>
<release version="4.0" date="TBA" description="Next release">
<action issue="COLLECTIONS-473" dev="tn" type="update" due-to="sebb"> <action issue="COLLECTIONS-473" dev="tn" type="update" due-to="sebb">
Made field "collection" in class "AbstractCollectionDecorator" private and added Made field "collection" in class "AbstractCollectionDecorator" private and added
setter "setCollection(Collection)" with scope protected to set the decorated collection setter "setCollection(Collection)" with scope protected to set the decorated collection

View File

@ -240,8 +240,12 @@ public class ListOrderedMap<K, V>
* *
* @param index the index in the Map to start at. * @param index the index in the Map to start at.
* @param map the Map containing the entries to be added. * @param map the Map containing the entries to be added.
* @throws IndexOutOfBoundsException if the index is out of range [0, size]
*/ */
public void putAll(int index, final Map<? extends K, ? extends V> map) { public void putAll(int index, final Map<? extends K, ? extends V> map) {
if (index < 0 || index > insertOrder.size()) {
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + insertOrder.size());
}
for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) { for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
final K key = entry.getKey(); final K key = entry.getKey();
final boolean contains = containsKey(key); final boolean contains = containsKey(key);
@ -437,10 +441,14 @@ public class ListOrderedMap<K, V>
* @param key the key * @param key the key
* @param value the value * @param value the value
* @return the value previously mapped to the key * @return the value previously mapped to the key
* @throws IndexOutOfBoundsException if the index is out of range * @throws IndexOutOfBoundsException if the index is out of range [0, size]
* @since 3.2 * @since 3.2
*/ */
public V put(int index, final K key, final V value) { public V put(int index, final K key, final V value) {
if (index < 0 || index > insertOrder.size()) {
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + insertOrder.size());
}
final Map<K, V> m = decorated(); final Map<K, V> m = decorated();
if (m.containsKey(key)) { if (m.containsKey(key)) {
final V result = m.remove(key); final V result = m.remove(key);