@Test public void testJoinAll() throws Exception { assertNull(CollectionUtils.joinAll(null, null)); assertNull(CollectionUtils.joinAll(null, "-")); Map<String, List<String>> expected = new HashMap<String, List<String>>(); expected.put("key1", Arrays.asList("1:a", "2:b", "3:c")); expected.put("key2", Arrays.asList("1:a", "2:b")); expected.put("key3", null); expected.put("key4", new ArrayList<String>()); Map<String, Map<String, String>> input = new HashMap<String, Map<String, String>>(); input.put("key1", CollectionUtils.toStringMap("1", "a", "2", "b", "3", "c")); input.put("key2", CollectionUtils.toStringMap("1", "a", "2", "b")); input.put("key3", null); input.put("key4", new HashMap<String, String>()); Map<String, List<String>> output = CollectionUtils.joinAll(input, ":"); for (Map.Entry<String, List<String>> entry : output.entrySet()) { if (entry.getValue() == null) continue; Collections.sort(entry.getValue()); } assertEquals(expected, output); }
public static Map<String, List<String>> joinAll(Map<String, Map<String, String>> map, String separator) { if (map == null) { return null; } Map<String, List<String>> result = new HashMap<String, List<String>>(); for (Map.Entry<String, Map<String, String>> entry : map.entrySet()) { result.put(entry.getKey(), join(entry.getValue(), separator)); } return result; }
CollectionUtils { public static Map<String, List<String>> joinAll(Map<String, Map<String, String>> map, String separator) { if (map == null) { return null; } Map<String, List<String>> result = new HashMap<String, List<String>>(); for (Map.Entry<String, Map<String, String>> entry : map.entrySet()) { result.put(entry.getKey(), join(entry.getValue(), separator)); } return result; } }
CollectionUtils { public static Map<String, List<String>> joinAll(Map<String, Map<String, String>> map, String separator) { if (map == null) { return null; } Map<String, List<String>> result = new HashMap<String, List<String>>(); for (Map.Entry<String, Map<String, String>> entry : map.entrySet()) { result.put(entry.getKey(), join(entry.getValue(), separator)); } return result; } private  CollectionUtils(); }
CollectionUtils { public static Map<String, List<String>> joinAll(Map<String, Map<String, String>> map, String separator) { if (map == null) { return null; } Map<String, List<String>> result = new HashMap<String, List<String>>(); for (Map.Entry<String, Map<String, String>> entry : map.entrySet()) { result.put(entry.getKey(), join(entry.getValue(), separator)); } return result; } private  CollectionUtils(); @SuppressWarnings({"unchecked", "rawtypes"}) static List<T> sort(List<T> list); static List<String> sortSimpleName(List<String> list); static Map<String, Map<String, String>> splitAll(Map<String, List<String>> list, String separator); static Map<String, List<String>> joinAll(Map<String, Map<String, String>> map, String separator); static Map<String, String> split(List<String> list, String separator); static List<String> join(Map<String, String> map, String separator); static String join(List<String> list, String separator); static boolean mapEquals(Map<?, ?> map1, Map<?, ?> map2); static Map<String, String> toStringMap(String... pairs); @SuppressWarnings("unchecked") static Map<K, V> toMap(Object... pairs); static boolean isEmpty(Collection<?> collection); static boolean isNotEmpty(Collection<?> collection); }
CollectionUtils { public static Map<String, List<String>> joinAll(Map<String, Map<String, String>> map, String separator) { if (map == null) { return null; } Map<String, List<String>> result = new HashMap<String, List<String>>(); for (Map.Entry<String, Map<String, String>> entry : map.entrySet()) { result.put(entry.getKey(), join(entry.getValue(), separator)); } return result; } private  CollectionUtils(); @SuppressWarnings({"unchecked", "rawtypes"}) static List<T> sort(List<T> list); static List<String> sortSimpleName(List<String> list); static Map<String, Map<String, String>> splitAll(Map<String, List<String>> list, String separator); static Map<String, List<String>> joinAll(Map<String, Map<String, String>> map, String separator); static Map<String, String> split(List<String> list, String separator); static List<String> join(Map<String, String> map, String separator); static String join(List<String> list, String separator); static boolean mapEquals(Map<?, ?> map1, Map<?, ?> map2); static Map<String, String> toStringMap(String... pairs); @SuppressWarnings("unchecked") static Map<K, V> toMap(Object... pairs); static boolean isEmpty(Collection<?> collection); static boolean isNotEmpty(Collection<?> collection);  }