TypeUtils { public static Map<String, String> fromDictionary(Dictionary<String, String> dictionary) { Map<String, String> result = new HashMap<String, String>(); Enumeration<String> keys = dictionary.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); result.put(key, dictionary.get(key)); } return result; } private  TypeUtils(); static Map<String, String> fromDictionary(Dictionary<String, String> dictionary); static Long[] toLong(long[] array); static long[] toPrimitive(Long[] array); @SuppressWarnings("unchecked") static T fromString(Class<T> type, String value); static Map<String, Class<? extends Object>> primitiveTypes; static Map<String, Class<? extends Object>> wrapperTypes; static Map<String, Class<? extends Object>> mathTypes; static Map<Class<? extends Object>, Class<? extends Object>> primitiveToWrapper; static Map<String, Class<? extends Object>> types; }
@Test public void testMapFromDictionary() throws Exception{ Dictionary<String, String> dictionary = new Hashtable<String, String>(); dictionary.put("one", "1"); dictionary.put("two", "2"); Map<String,String> map = fromDictionary(dictionary); assertEquals(2, map.size()); assertEquals("1", map.get("one")); assertEquals("2", map.get("two")); }