commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1557342 - /commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/MapUtils.java
Date Sat, 11 Jan 2014 11:13:06 GMT
Author: britter
Date: Sat Jan 11 11:13:06 2014
New Revision: 1557342

URL: http://svn.apache.org/r1557342
Log:
Generics for MapUtils

Modified:
    commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/MapUtils.java

Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/MapUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/MapUtils.java?rev=1557342&r1=1557341&r2=1557342&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/MapUtils.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/MapUtils.java Sat
Jan 11 11:13:06 2014
@@ -37,13 +37,13 @@ public class MapUtils
      * @param source the source map
      * @return the clone of the source map
      */
-    public static Map copy(final Map source) {
+    public static <K, V> Map<K, V> copy(final Map<K, V> source) {
 
         if (source == null) {
             return null;
         }
 
-        final Map result = new HashMap();
+        final Map<K, V> result = new HashMap<K, V>();
         result.putAll(source);
         return result;
     }
@@ -57,20 +57,20 @@ public class MapUtils
      * @param prefix the prefix used for all names
      * @return the clone of the source map
      */
-    public static Map prefix(final Map source, final String prefix) {
+    public static <K, V> Map<String, V> prefix(final Map<K, V> source,
final String prefix) {
 
         if (source == null) {
             return null;
         }
 
-        final Map result = new HashMap();
+        final Map<String, V> result = new HashMap<String, V>();
 
-        final Iterator iter = source.entrySet().iterator();
+        final Iterator<Map.Entry<K, V>> iter = source.entrySet().iterator();
 
         while (iter.hasNext()) {
-            final Map.Entry entry = (Map.Entry) iter.next();
-            final Object key = entry.getKey();
-            final Object value = entry.getValue();
+            final Map.Entry<K, V> entry = iter.next();
+            final K key = entry.getKey();
+            final V value = entry.getValue();
             result.put(prefix + '.' + key.toString(), value);
         }
 
@@ -85,7 +85,7 @@ public class MapUtils
      * @param rhs the second map
      * @return the merged map
      */
-    public static Map merge(final Map lhs, final Map rhs) {
+    public static <K, V> Map<K, V> merge(final Map<K, V> lhs, final Map<K,
V> rhs) {
 
         Map result = null;
 



Mime
View raw message