@Test void testToStringArrayMap() { MultiMap<String> mm = new MultiMap<>(); mm.putValues("food", "apple", "cherry", "raspberry"); mm.put("color", "red"); mm.putValues("amount", "bushel", "pint"); assertMapSize(mm, 3); Map<String, String[]> sam = mm.toStringArrayMap(); assertEquals(3, sam.size()); assertArray("toStringArrayMap(food)", sam.get("food"), "apple", "cherry", "raspberry"); assertArray("toStringArrayMap(color)", sam.get("color"), "red"); assertArray("toStringArrayMap(amount)", sam.get("amount"), "bushel", "pint"); }
public Map<String, String[]> toStringArrayMap() { HashMap<String, String[]> map = new HashMap<String, String[]>(size() * 3 / 2) { private static final long serialVersionUID = -6129887569971781626L; @Override public String toString() { StringBuilder b = new StringBuilder(); b.append('{'); for (String k : super.keySet()) { if (b.length() > 1) b.append(','); b.append(k); b.append('='); b.append(Arrays.asList(super.get(k))); } b.append('}'); return b.toString(); } }; for (Entry<String, List<V>> entry : entrySet()) { String[] a = null; if (entry.getValue() != null) { a = new String[entry.getValue().size()]; a = entry.getValue().toArray(a); } map.put(entry.getKey(), a); } return map; }
MultiMap extends HashMap<String, List<V>> { public Map<String, String[]> toStringArrayMap() { HashMap<String, String[]> map = new HashMap<String, String[]>(size() * 3 / 2) { private static final long serialVersionUID = -6129887569971781626L; @Override public String toString() { StringBuilder b = new StringBuilder(); b.append('{'); for (String k : super.keySet()) { if (b.length() > 1) b.append(','); b.append(k); b.append('='); b.append(Arrays.asList(super.get(k))); } b.append('}'); return b.toString(); } }; for (Entry<String, List<V>> entry : entrySet()) { String[] a = null; if (entry.getValue() != null) { a = new String[entry.getValue().size()]; a = entry.getValue().toArray(a); } map.put(entry.getKey(), a); } return map; } }
MultiMap extends HashMap<String, List<V>> { public Map<String, String[]> toStringArrayMap() { HashMap<String, String[]> map = new HashMap<String, String[]>(size() * 3 / 2) { private static final long serialVersionUID = -6129887569971781626L; @Override public String toString() { StringBuilder b = new StringBuilder(); b.append('{'); for (String k : super.keySet()) { if (b.length() > 1) b.append(','); b.append(k); b.append('='); b.append(Arrays.asList(super.get(k))); } b.append('}'); return b.toString(); } }; for (Entry<String, List<V>> entry : entrySet()) { String[] a = null; if (entry.getValue() != null) { a = new String[entry.getValue().size()]; a = entry.getValue().toArray(a); } map.put(entry.getKey(), a); } return map; } MultiMap();  MultiMap(Map<String, List<V>> map);  MultiMap(MultiMap<V> map); }
MultiMap extends HashMap<String, List<V>> { public Map<String, String[]> toStringArrayMap() { HashMap<String, String[]> map = new HashMap<String, String[]>(size() * 3 / 2) { private static final long serialVersionUID = -6129887569971781626L; @Override public String toString() { StringBuilder b = new StringBuilder(); b.append('{'); for (String k : super.keySet()) { if (b.length() > 1) b.append(','); b.append(k); b.append('='); b.append(Arrays.asList(super.get(k))); } b.append('}'); return b.toString(); } }; for (Entry<String, List<V>> entry : entrySet()) { String[] a = null; if (entry.getValue() != null) { a = new String[entry.getValue().size()]; a = entry.getValue().toArray(a); } map.put(entry.getKey(), a); } return map; } MultiMap();  MultiMap(Map<String, List<V>> map);  MultiMap(MultiMap<V> map); List<V> getValues(String name); V getValue(String name, int i); String getString(String name); List<V> put(String name, V value); void putAllValues(Map<String, V> input); List<V> putValues(String name, List<V> values); @SafeVarargs final List<V> putValues(String name, V... values); void add(String name, V value); void addValues(String name, List<V> values); void addValues(String name, V[] values); boolean addAllValues(MultiMap<V> map); boolean removeValue(String name, V value); boolean containsSimpleValue(V value); @Override String toString(); Map<String, String[]> toStringArrayMap(); }
MultiMap extends HashMap<String, List<V>> { public Map<String, String[]> toStringArrayMap() { HashMap<String, String[]> map = new HashMap<String, String[]>(size() * 3 / 2) { private static final long serialVersionUID = -6129887569971781626L; @Override public String toString() { StringBuilder b = new StringBuilder(); b.append('{'); for (String k : super.keySet()) { if (b.length() > 1) b.append(','); b.append(k); b.append('='); b.append(Arrays.asList(super.get(k))); } b.append('}'); return b.toString(); } }; for (Entry<String, List<V>> entry : entrySet()) { String[] a = null; if (entry.getValue() != null) { a = new String[entry.getValue().size()]; a = entry.getValue().toArray(a); } map.put(entry.getKey(), a); } return map; } MultiMap();  MultiMap(Map<String, List<V>> map);  MultiMap(MultiMap<V> map); List<V> getValues(String name); V getValue(String name, int i); String getString(String name); List<V> put(String name, V value); void putAllValues(Map<String, V> input); List<V> putValues(String name, List<V> values); @SafeVarargs final List<V> putValues(String name, V... values); void add(String name, V value); void addValues(String name, List<V> values); void addValues(String name, V[] values); boolean addAllValues(MultiMap<V> map); boolean removeValue(String name, V value); boolean containsSimpleValue(V value); @Override String toString(); Map<String, String[]> toStringArrayMap();  }