You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/10/20 03:04:54 UTC

svn commit: r1024473 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java

Author: sebb
Date: Wed Oct 20 01:04:54 2010
New Revision: 1024473

URL: http://svn.apache.org/viewvc?rev=1024473&view=rev
Log:
Raw types and unchecked casts

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java?rev=1024473&r1=1024472&r2=1024473&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java Wed Oct 20 01:04:54 2010
@@ -1618,9 +1618,8 @@ public class MapUtils {
      * @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
      */
-    // TODO: Generics
-    public static void populateMap(Map map, Collection collection, Transformer keyTransformer) {
-        populateMap(map, collection, keyTransformer, TransformerUtils.nopTransformer());
+    public static <K, V> void populateMap(Map<K, V> map, Collection<? extends V> collection, Transformer<V, K> keyTransformer) {
+        populateMap(map, collection, keyTransformer, TransformerUtils.<V>nopTransformer());
     }
 
     /**
@@ -1634,11 +1633,12 @@ public class MapUtils {
      * @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
      */
-    // TODO: Generics
-    public static void populateMap(Map map, Collection collection, Transformer keyTransformer, Transformer valueTransformer) {
-        Iterator iter = collection.iterator();
+    public static <K, V, E> void populateMap(Map<K, V> map, Collection<? extends E> collection, 
+            Transformer<E, K> keyTransformer, 
+            Transformer<E, V> valueTransformer) {
+        Iterator<? extends E> iter = collection.iterator();
         while (iter.hasNext()) {
-            Object temp = iter.next();
+            E temp = iter.next();
             map.put(keyTransformer.transform(temp), valueTransformer.transform(temp));
         }
     }