MultiMap extends HashMap<String, List<V>> { public List<V> put(String name, V value) { if (value == null) { return super.put(name, null); } List<V> vals = new ArrayList<>(); vals.add(value); return put(name, vals); } 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();  }
@Test void testPut() { MultiMap<String> mm = new MultiMap<>(); String key = "formats"; mm.put(key, "gzip"); assertMapSize(mm, 1); assertValues(mm, key, "gzip"); }
@Test void testPutNullString() { MultiMap<String> mm = new MultiMap<>(); String key = "formats"; String val = null; mm.put(key, val); assertMapSize(mm, 1); assertNullValues(mm, key); }
@Test void testPutNullList() { MultiMap<String> mm = new MultiMap<>(); String key = "formats"; List<String> vals = null; mm.put(key, vals); assertMapSize(mm, 1); assertNullValues(mm, key); }
@Test void testPutReplace() { MultiMap<String> mm = new MultiMap<>(); String key = "formats"; Object ret; ret = mm.put(key, "gzip"); assertMapSize(mm, 1); assertValues(mm, key, "gzip"); assertNull(ret); Object orig = mm.get(key); ret = mm.put(key, "jar"); assertMapSize(mm, 1); assertValues(mm, key, "jar"); assertEquals(orig, ret); }
@Test void testPutAllMultiMapSimple() { MultiMap<String> mm = new MultiMap<>(); assertMapSize(mm, 0); MultiMap<String> input = new MultiMap<>(); input.put("food", "apple"); input.put("color", "red"); input.put("amount", "bushel"); mm.putAll(input); assertMapSize(mm, 3); assertValues(mm, "food", "apple"); assertValues(mm, "color", "red"); assertValues(mm, "amount", "bushel"); }