@Test public void testAddArrayValueInitialized() { Map<String, String[]> map = new TreeMap<String, String[]>(); Assert.assertNull(map.get("lincoln")); Maps.addArrayValue(map, "lincoln", "baxter"); Maps.addArrayValue(map, "lincoln", "III"); Assert.assertEquals("baxter", map.get("lincoln")[0]); Assert.assertEquals("III", map.get("lincoln")[1]); }
public static <T> void addArrayValue(final Map<T, String[]> map, final T key, final String value) { if (!map.containsKey(key)) { map.put(key, Arrays.asList(value).toArray(new String[] {})); } else { String[] values = map.get(key); List<String> list = new ArrayList<String>(Arrays.asList(values)); list.add(value); map.put(key, list.toArray(new String[] {})); } }
Maps { public static <T> void addArrayValue(final Map<T, String[]> map, final T key, final String value) { if (!map.containsKey(key)) { map.put(key, Arrays.asList(value).toArray(new String[] {})); } else { String[] values = map.get(key); List<String> list = new ArrayList<String>(Arrays.asList(values)); list.add(value); map.put(key, list.toArray(new String[] {})); } } }
Maps { public static <T> void addArrayValue(final Map<T, String[]> map, final T key, final String value) { if (!map.containsKey(key)) { map.put(key, Arrays.asList(value).toArray(new String[] {})); } else { String[] values = map.get(key); List<String> list = new ArrayList<String>(Arrays.asList(values)); list.add(value); map.put(key, list.toArray(new String[] {})); } }  }
Maps { public static <T> void addArrayValue(final Map<T, String[]> map, final T key, final String value) { if (!map.containsKey(key)) { map.put(key, Arrays.asList(value).toArray(new String[] {})); } else { String[] values = map.get(key); List<String> list = new ArrayList<String>(Arrays.asList(values)); list.add(value); map.put(key, list.toArray(new String[] {})); } }  @SuppressWarnings("unchecked") static void addListValue(final Map<K, List<T>> map, final K key, final T value); static void addArrayValue(final Map<T, String[]> map, final T key, final String value); static T getListValue(final Map<String, List<T>> values, final String name, final int index); static Map<String, String[]> toArrayMap(final Map<String, List<String>> parameterMap); }
Maps { public static <T> void addArrayValue(final Map<T, String[]> map, final T key, final String value) { if (!map.containsKey(key)) { map.put(key, Arrays.asList(value).toArray(new String[] {})); } else { String[] values = map.get(key); List<String> list = new ArrayList<String>(Arrays.asList(values)); list.add(value); map.put(key, list.toArray(new String[] {})); } }  @SuppressWarnings("unchecked") static void addListValue(final Map<K, List<T>> map, final K key, final T value); static void addArrayValue(final Map<T, String[]> map, final T key, final String value); static T getListValue(final Map<String, List<T>> values, final String name, final int index); static Map<String, String[]> toArrayMap(final Map<String, List<String>> parameterMap);  }