CollectionUtil { public static <K, V> void toMapWithStringKeys(final Map<Class<? extends K>, V> map, final Map<String, V> mapAsStrings) { for (final Map.Entry<Class<? extends K>, V> entry : map.entrySet()) { mapAsStrings.put( entry.getKey().getName(), 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 shouldConvertMapToStringKeys() { final Map<Class<? extends Number>, String> map = new HashMap<>(); populateClassKeyMap(map); final Map<String, String> result = CollectionUtil.toMapWithStringKeys(map); final Map<String, String> expectedResult = new HashMap<>(); populateStringKeyMap(expectedResult); assertEquals(expectedResult, result); }
@Test public void shouldConvertMapToStringKeysWithProvidedMap() { final Map<Class<? extends Number>, String> map = new HashMap<>(); populateClassKeyMap(map); final Map<String, String> result = new LinkedHashMap<>(); CollectionUtil.toMapWithStringKeys(map, result); final Map<String, String> expectedResult = new LinkedHashMap<>(); populateStringKeyMap(expectedResult); assertEquals(expectedResult, result); }