commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1088107 - /commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/names/DiscoverMappedNames.java
Date Sat, 02 Apr 2011 20:21:05 GMT
Author: simonetripodi
Date: Sat Apr  2 20:21:05 2011
New Revision: 1088107

URL: http://svn.apache.org/viewvc?rev=1088107&view=rev
Log:
added generics to internal Map
internal Map made private final
no more need to check value type at runtime

Modified:
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/names/DiscoverMappedNames.java

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/names/DiscoverMappedNames.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/names/DiscoverMappedNames.java?rev=1088107&r1=1088106&r2=1088107&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/names/DiscoverMappedNames.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/names/DiscoverMappedNames.java
Sat Apr  2 20:21:05 2011
@@ -17,6 +17,7 @@
 package org.apache.commons.discovery.resource.names;
 
 import java.util.Hashtable;
+import java.util.Map;
 
 import org.apache.commons.discovery.ResourceNameDiscover;
 import org.apache.commons.discovery.ResourceNameIterator;
@@ -45,7 +46,7 @@ public class DiscoverMappedNames
         log = _log;
     }
     
-    private Hashtable mapping = new Hashtable();  // String name ==> String[] newNames
+    private final Map<String, String[]> mapping = new Hashtable<String, String[]>();
 // String name ==> String[] newNames
     
     /** Construct a new resource discoverer
      */
@@ -53,7 +54,7 @@ public class DiscoverMappedNames
     }
     
     public void map(String fromName, String toName) {
-        mapping.put(fromName, toName);
+        map(fromName, new String[]{ toName });
     }
     
     public void map(String fromName, String [] toNames) {
@@ -68,17 +69,8 @@ public class DiscoverMappedNames
             log.debug("find: resourceName='" + resourceName + "', mapping to constants");
         }
         
-        final Object obj = mapping.get(resourceName);
+        final String[] names = mapping.get(resourceName);
 
-        final String[] names;
-        if (obj instanceof String) {
-            names = new String[] { (String)obj };
-        } else if (obj instanceof String[]) {
-            names = (String[])obj;
-        } else {
-            names = null;
-        }
-        
         return new ResourceNameIterator() {
 
             private int idx = 0;



Mime
View raw message