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/05/08 13:35:21 UTC

svn commit: r1480230 - in /commons/proper/collections/trunk: RELEASE-NOTES.txt src/changes/changes.xml src/main/java/org/apache/commons/collections4/MapUtils.java

Author: tn
Date: Wed May  8 11:35:20 2013
New Revision: 1480230

URL: http://svn.apache.org/r1480230
Log:
[COLLECTIONS-466] Replaced Collection with Iterable in MapUtils.populateMap methods.

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/MapUtils.java

Modified: commons/proper/collections/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/RELEASE-NOTES.txt?rev=1480230&r1=1480229&r2=1480230&view=diff
==============================================================================
--- commons/proper/collections/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/collections/trunk/RELEASE-NOTES.txt Wed May  8 11:35:20 2013
@@ -102,7 +102,7 @@ New methods in *Utils
  o [COLLECTIONS-286] CollectionUtils#extractSingleton(Collection). Thanks to Geoffrey De Smet.  
  o [COLLECTIONS-263] MapUtils#populateMap(MultiMap, ...) to support also "MultiMap" instances as input. Thanks to John Hunsley.  
  o [COLLECTIONS-235] ListUtils#indexOf(List, Predicate). Thanks to Nathan Egge. 
- o [COLLECTIONS-194] MapUtils#populateMap(Map, Collection, Transformer, ...). Thanks to Dave Meikle. 
+ o [COLLECTIONS-194] MapUtils#populateMap(Map, Iterable, Transformer, ...). Thanks to Dave Meikle. 
 
 
 New features

Modified: commons/proper/collections/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/changes/changes.xml?rev=1480230&r1=1480229&r2=1480230&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/changes/changes.xml (original)
+++ commons/proper/collections/trunk/src/changes/changes.xml Wed May  8 11:35:20 2013
@@ -454,7 +454,7 @@
       Added support for resettable iterators in "IteratorIterable".
     </action>
     <action issue="COLLECTIONS-194" dev="bayard" type="add" due-to="Dave Meikle">
-      Added methods "MapUtils#populateMap(Map, Collection, Transformer, ...)".
+      Added methods "MapUtils#populateMap(Map, Iterable, Transformer, ...)".
     </action>
     <action issue="COLLECTIONS-182" dev="mbenson" type="update" due-to="Jim Cakalic">
       "CollectionUtils#forAllDo(Collection, Closure)" now returns the provided closure.

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MapUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MapUtils.java?rev=1480230&r1=1480229&r2=1480230&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MapUtils.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/MapUtils.java Wed May  8 11:35:20 2013
@@ -1666,38 +1666,38 @@ public class MapUtils {
     }
 
     /**
-     * Populates a Map using the supplied <code>Transformer</code> to transform the collection
-     * values into keys, using the unaltered collection value as the value in the <code>Map</code>.
+     * Populates a Map using the supplied <code>Transformer</code> to transform the elements
+     * into keys, using the unaltered element as the value in the <code>Map</code>.
      *
      * @param <K>  the key type
      * @param <V>  the value type
      * @param map the <code>Map</code> to populate.
-     * @param collection the <code>Collection</code> to use as input values for the map.
-     * @param keyTransformer the <code>Transformer</code> used to transform the collection value into a key value
-     * @throws NullPointerException if the map, collection or transformer are null
+     * @param elements the <code>Iterable</code> containing the input values for the map.
+     * @param keyTransformer the <code>Transformer</code> used to transform the element into a key value
+     * @throws NullPointerException if the map, elements or transformer are null
      */
-    public static <K, V> void populateMap(final Map<K, V> map, final Collection<? extends V> collection,
+    public static <K, V> void populateMap(final Map<K, V> map, final Iterable<? extends V> elements,
                                           final Transformer<V, K> keyTransformer) {
-        populateMap(map, collection, keyTransformer, TransformerUtils.<V>nopTransformer());
+        populateMap(map, elements, keyTransformer, TransformerUtils.<V>nopTransformer());
     }
 
     /**
-     * Populates a Map using the supplied <code>Transformer</code>s to transform the collection
-     * values into keys and values.
+     * Populates a Map using the supplied <code>Transformer</code>s to transform the elements
+     * into keys and values.
      *
      * @param <K>  the key type
      * @param <V>  the value type
-     * @param <E>  the type of object contained in the {@link Collection}
+     * @param <E>  the type of object contained in the {@link Iterable}
      * @param map the <code>Map</code> to populate.
-     * @param collection the <code>Collection</code> to use as input values for the map.
-     * @param keyTransformer the <code>Transformer</code> used to transform the collection value into a key value
-     * @param valueTransformer the <code>Transformer</code> used to transform the collection value into a value
-     * @throws NullPointerException if the map, collection or transformers are null
+     * @param elements the <code>Iterable</code> containing the input values for the map.
+     * @param keyTransformer the <code>Transformer</code> used to transform the element into a key value
+     * @param valueTransformer the <code>Transformer</code> used to transform the element into a value
+     * @throws NullPointerException if the map, elements or transformers are null
      */
-    public static <K, V, E> void populateMap(final Map<K, V> map, final Collection<? extends E> collection,
+    public static <K, V, E> void populateMap(final Map<K, V> map, final Iterable<? extends E> elements,
                                              final Transformer<E, K> keyTransformer,
                                              final Transformer<E, V> valueTransformer) {
-        final Iterator<? extends E> iter = collection.iterator();
+        final Iterator<? extends E> iter = elements.iterator();
         while (iter.hasNext()) {
             final E temp = iter.next();
             map.put(keyTransformer.transform(temp), valueTransformer.transform(temp));
@@ -1705,38 +1705,38 @@ public class MapUtils {
     }
 
     /**
-     * Populates a MultiMap using the supplied <code>Transformer</code> to transform the collection
-     * values into keys, using the unaltered collection value as the value in the <code>MultiMap</code>.
+     * Populates a MultiMap using the supplied <code>Transformer</code> to transform the elements
+     * into keys, using the unaltered element as the value in the <code>MultiMap</code>.
      *
      * @param <K>  the key type
      * @param <V>  the value type
      * @param map the <code>MultiMap</code> to populate.
-     * @param collection the <code>Collection</code> to use as input values for the map.
-     * @param keyTransformer the <code>Transformer</code> used to transform the collection value into a key value
-     * @throws NullPointerException if the map, collection or transformer are null
+     * @param elements the <code>Iterable</code> to use as input values for the map.
+     * @param keyTransformer the <code>Transformer</code> used to transform the element into a key value
+     * @throws NullPointerException if the map, elements or transformer are null
      */
-    public static <K, V> void populateMap(final MultiMap<K, V> map, final Collection<? extends V> collection,
+    public static <K, V> void populateMap(final MultiMap<K, V> map, final Iterable<? extends V> elements,
                                           final Transformer<V, K> keyTransformer) {
-        populateMap(map, collection, keyTransformer, TransformerUtils.<V>nopTransformer());
+        populateMap(map, elements, keyTransformer, TransformerUtils.<V>nopTransformer());
     }
 
     /**
-     * Populates a MultiMap using the supplied <code>Transformer</code>s to transform the collection
-     * values into keys and values.
+     * Populates a MultiMap using the supplied <code>Transformer</code>s to transform the elements
+     * into keys and values.
      *
      * @param <K>  the key type
      * @param <V>  the value type
-     * @param <E>  the type of object contained in the {@link Collection}
+     * @param <E>  the type of object contained in the {@link Iterable}
      * @param map the <code>MultiMap</code> to populate.
-     * @param collection the <code>Collection</code> to use as input values for the map.
-     * @param keyTransformer the <code>Transformer</code> used to transform the collection value into a key value
-     * @param valueTransformer the <code>Transformer</code> used to transform the collection value into a value
+     * @param elements the <code>Iterable</code> containing the input values for the map.
+     * @param keyTransformer the <code>Transformer</code> used to transform the element into a key value
+     * @param valueTransformer the <code>Transformer</code> used to transform the element into a value
      * @throws NullPointerException if the map, collection or transformers are null
      */
-    public static <K, V, E> void populateMap(final MultiMap<K, V> map, final Collection<? extends E> collection,
+    public static <K, V, E> void populateMap(final MultiMap<K, V> map, final Iterable<? extends E> elements,
                                              final Transformer<E, K> keyTransformer,
                                              final Transformer<E, V> valueTransformer) {
-        final Iterator<? extends E> iter = collection.iterator();
+        final Iterator<? extends E> iter = elements.iterator();
         while (iter.hasNext()) {
             final E temp = iter.next();
             map.put(keyTransformer.transform(temp), valueTransformer.transform(temp));