@Test public void testKeySet() { final EventList<String> source = new BasicEventList<>(); final Map<String, String> eventMap = GlazedLists.syncEventListToMap(source, new FirstLetterFunction()); assertTrue(eventMap.isEmpty()); assertTrue(eventMap.keySet().isEmpty()); assertFalse(eventMap.keySet().contains("J")); source.addAll(GlazedListsTests.delimitedStringToList("James Kevin Andy Holger")); assertEquals(4, source.size()); assertEquals(4, eventMap.size()); assertEquals(4, eventMap.keySet().size()); assertEquals(new HashSet<>(Arrays.asList("J", "K", "A", "H")), eventMap.keySet()); assertTrue(eventMap.keySet().contains("J")); assertTrue(eventMap.keySet().contains("K")); assertTrue(eventMap.keySet().contains("A")); assertTrue(eventMap.keySet().contains("H")); assertTrue(eventMap.keySet().remove("J")); assertEquals(3, source.size()); assertEquals(3, eventMap.size()); assertEquals(3, eventMap.keySet().size()); assertEquals(new HashSet<>(Arrays.asList("K", "A", "H")), eventMap.keySet()); assertFalse(eventMap.keySet().remove("J")); assertEquals(3, source.size()); assertEquals(3, eventMap.size()); assertEquals(3, eventMap.keySet().size()); assertEquals(new HashSet<>(Arrays.asList("K", "A", "H")), eventMap.keySet()); try { eventMap.keySet().add("J"); fail("failed to throw an UnsupportedOperationException! Implementing add() makes no sense!"); } catch (UnsupportedOperationException e) { } assertFalse(eventMap.keySet().remove("J")); eventMap.keySet().clear(); assertTrue(eventMap.isEmpty()); assertTrue(eventMap.keySet().isEmpty()); assertFalse(eventMap.keySet().contains("J")); }
@Override public Set<K> keySet() { if (this.keySet == null) this.keySet = new KeySet(); return this.keySet; }
FunctionListMap implements DisposableMap<K, V> { @Override public Set<K> keySet() { if (this.keySet == null) this.keySet = new KeySet(); return this.keySet; } }
FunctionListMap implements DisposableMap<K, V> { @Override public Set<K> keySet() { if (this.keySet == null) this.keySet = new KeySet(); return this.keySet; } FunctionListMap(EventList<V> source, FunctionList.Function<V, K> keyFunction); }
FunctionListMap implements DisposableMap<K, V> { @Override public Set<K> keySet() { if (this.keySet == null) this.keySet = new KeySet(); return this.keySet; } FunctionListMap(EventList<V> source, FunctionList.Function<V, K> keyFunction); @Override void dispose(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> m); @Override void clear(); @Override V remove(Object key); @Override Collection<V> values(); @Override Set<K> keySet(); @Override Set<Entry<K, V>> entrySet(); @Override void forEach(BiConsumer<? super K, ? super V> action); @Override boolean equals(Object o); @Override int hashCode(); }
FunctionListMap implements DisposableMap<K, V> { @Override public Set<K> keySet() { if (this.keySet == null) this.keySet = new KeySet(); return this.keySet; } FunctionListMap(EventList<V> source, FunctionList.Function<V, K> keyFunction); @Override void dispose(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> m); @Override void clear(); @Override V remove(Object key); @Override Collection<V> values(); @Override Set<K> keySet(); @Override Set<Entry<K, V>> entrySet(); @Override void forEach(BiConsumer<? super K, ? super V> action); @Override boolean equals(Object o); @Override int hashCode();  }