CaselessMultivaluedMap implements ExtMultivaluedMap<String, T>, Serializable { @Override public Set<String> keySet() { if (keys == null) { keys = new KeySet(); } return keys; } CaselessMultivaluedMap();  CaselessMultivaluedMap(int capacity);  CaselessMultivaluedMap(Map<String, List<T>> m); @Override void add(String key, T value); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override Set<Entry<String, List<T>>> entrySet(); @Override List<T> get(Object key); @Override T getFirst(String key); @Override void addAll(String key, T... newValues); @Override void addAll(String key, List<T> valueList); @Override void addFirst(String key, T value); @Override boolean equalsIgnoreValueOrder(MultivaluedMap<String, T> otherMap); @Override List<T> getList(String key); @Override boolean isEmpty(); @Override Set<String> keySet(); @Override List<T> put(String key, List<T> value); @Override void putAll(Map<? extends String, ? extends List<T>> m); @Override void putSingle(String key, T value); @Override List<T> remove(Object key); @Override int size(); @Override Collection<List<T>> values(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testKeySet() { Set<String> keys = map.keySet(); map.put("k", newArrayList("a", "b")); map.put("e", newArrayList("c", "d")); map.put("Y", newArrayList("e", "f")); assertEquals(3, map.size()); assertEquals(3, keys.size()); assertTrue(keys.contains("K")); assertTrue(keys.contains("Y")); assertTrue(keys.contains("e")); assertTrue(keys.remove("Y")); assertEquals(2, map.size()); assertEquals(2, keys.size()); assertTrue(keys.contains("K")); assertTrue(keys.contains("e")); assertFalse(keys.contains("Y")); for (Iterator<String> iterator = keys.iterator(); iterator.hasNext(); ) { iterator.next(); iterator.remove(); } assertEquals(0, map.size()); assertEquals(0, keys.size()); }