CollectionUtil { public static <K, V> void toMapWithClassKeys(final Map<String, V> mapAsStrings, final Map<Class<? extends K>, V> map) throws ClassNotFoundException { for (final Map.Entry<String, V> entry : mapAsStrings.entrySet()) { map.put( (Class) Class.forName(SimpleClassNameIdResolver.getClassName(entry.getKey())), entry.getValue() ); } } private  CollectionUtil(); static Iterable[] toIterableArray(final Collection<? extends Iterable> collection); static TreeSet<T> treeSet(final T item); static TreeSet<T> treeSet(final T[] items); static void toMapWithClassKeys(final Map<String, V> mapAsStrings, final Map<Class<? extends K>, V> map); static Map<Class<? extends K>, V> toMapWithClassKeys(final Map<String, V> mapAsStrings); static void toMapWithStringKeys(final Map<Class<? extends K>, V> map, final Map<String, V> mapAsStrings); static Map<String, V> toMapWithStringKeys(final Map<Class<? extends K>, V> map); static boolean containsAny(final Collection collection, final Object[] objects); static boolean anyMissing(final Collection collection, final Object[] objects); static boolean distinct(final Collection<T> collection);  }
@Test public void shouldConvertMapToClassKeys() throws ClassNotFoundException { final Map<String, String> map = new HashMap<>(); populateStringKeyMap(map); final Map<Class<? extends Number>, String> result = CollectionUtil.toMapWithClassKeys(map); final Map<Class<? extends Number>, String> expectedResult = new HashMap<>(); populateClassKeyMap(expectedResult); assertEquals(expectedResult, result); }
@Test public void shouldConvertMapToClassKeysWithProvidedMap() throws ClassNotFoundException { final Map<String, String> map = new HashMap<>(); populateStringKeyMap(map); final Map<Class<? extends Number>, String> result = new LinkedHashMap<>(); CollectionUtil.toMapWithClassKeys(map, result); final Map<Class<? extends Number>, String> expectedResult = new LinkedHashMap<>(); populateClassKeyMap(expectedResult); assertEquals(expectedResult, result); }