@Test void testToString() { MultiMap<String> mm = new MultiMap<>(); mm.put("color", "red"); assertEquals("{color=red}", mm.toString()); mm.putValues("food", "apple", "cherry", "raspberry"); assertEquals("{color=red, food=[apple, cherry, raspberry]}", mm.toString()); }
@Override public String toString() { Iterator<Entry<String, List<V>>> iter = entrySet().iterator(); StringBuilder sb = new StringBuilder(); sb.append('{'); boolean delim = false; while (iter.hasNext()) { Entry<String, List<V>> e = iter.next(); if (delim) { sb.append(", "); } String key = e.getKey(); List<V> vals = e.getValue(); sb.append(key); sb.append('='); if (vals.size() == 1) { sb.append(vals.get(0)); } else { sb.append(vals); } delim = true; } sb.append('}'); return sb.toString(); }
MultiMap extends HashMap<String, List<V>> { @Override public String toString() { Iterator<Entry<String, List<V>>> iter = entrySet().iterator(); StringBuilder sb = new StringBuilder(); sb.append('{'); boolean delim = false; while (iter.hasNext()) { Entry<String, List<V>> e = iter.next(); if (delim) { sb.append(", "); } String key = e.getKey(); List<V> vals = e.getValue(); sb.append(key); sb.append('='); if (vals.size() == 1) { sb.append(vals.get(0)); } else { sb.append(vals); } delim = true; } sb.append('}'); return sb.toString(); } }
MultiMap extends HashMap<String, List<V>> { @Override public String toString() { Iterator<Entry<String, List<V>>> iter = entrySet().iterator(); StringBuilder sb = new StringBuilder(); sb.append('{'); boolean delim = false; while (iter.hasNext()) { Entry<String, List<V>> e = iter.next(); if (delim) { sb.append(", "); } String key = e.getKey(); List<V> vals = e.getValue(); sb.append(key); sb.append('='); if (vals.size() == 1) { sb.append(vals.get(0)); } else { sb.append(vals); } delim = true; } sb.append('}'); return sb.toString(); } MultiMap();  MultiMap(Map<String, List<V>> map);  MultiMap(MultiMap<V> map); }
MultiMap extends HashMap<String, List<V>> { @Override public String toString() { Iterator<Entry<String, List<V>>> iter = entrySet().iterator(); StringBuilder sb = new StringBuilder(); sb.append('{'); boolean delim = false; while (iter.hasNext()) { Entry<String, List<V>> e = iter.next(); if (delim) { sb.append(", "); } String key = e.getKey(); List<V> vals = e.getValue(); sb.append(key); sb.append('='); if (vals.size() == 1) { sb.append(vals.get(0)); } else { sb.append(vals); } delim = true; } sb.append('}'); return sb.toString(); } 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>> { @Override public String toString() { Iterator<Entry<String, List<V>>> iter = entrySet().iterator(); StringBuilder sb = new StringBuilder(); sb.append('{'); boolean delim = false; while (iter.hasNext()) { Entry<String, List<V>> e = iter.next(); if (delim) { sb.append(", "); } String key = e.getKey(); List<V> vals = e.getValue(); sb.append(key); sb.append('='); if (vals.size() == 1) { sb.append(vals.get(0)); } else { sb.append(vals); } delim = true; } sb.append('}'); return sb.toString(); } 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();  }