@Test public void testPutAll() { final EventList<String> source = new BasicEventList<>(); final Map<Comparable<String>, List<String>> eventMap = GlazedLists.syncEventListToMultiMap(source, new FirstLetterFunction()); Map<Comparable<String>, List<String>> values = new HashMap<>(); assertTrue(eventMap.values().isEmpty()); values.put("J", GlazedListsTests.delimitedStringToList("James")); eventMap.putAll(values); assertEquals(1, eventMap.size()); assertEquals(GlazedListsTests.delimitedStringToList("James"), eventMap.get("J")); values.clear(); values.put("J", GlazedListsTests.delimitedStringToList("Jesse Jiries")); values.put("K", GlazedListsTests.delimitedStringToList("Katie")); values.put("W", GlazedListsTests.delimitedStringToList("Wilson")); eventMap.putAll(values); assertEquals(3, eventMap.size()); assertEquals(GlazedListsTests.delimitedStringToList("Jesse Jiries"), eventMap.get("J")); assertEquals(GlazedListsTests.delimitedStringToList("Katie"), eventMap.get("K")); assertEquals(GlazedListsTests.delimitedStringToList("Wilson"), eventMap.get("W")); try { values.clear(); values.put("Z", GlazedListsTests.delimitedStringToList("Ashford")); eventMap.putAll(values); fail("failed to receive IllegalArgumentException when using a key and value that do not agree"); } catch (IllegalArgumentException iae) { } try { values.clear(); values.put("Z", GlazedListsTests.delimitedStringToList("Zorro Ashford")); eventMap.putAll(values); fail("failed to receive IllegalArgumentException when using a key and value that do not agree"); } catch (IllegalArgumentException iae) { } }
@Override public void putAll(Map<? extends K, ? extends List<V>> m) { for (Iterator<? extends Entry<? extends K, ? extends List<V>>> i = m.entrySet().iterator(); i.hasNext();) { final Entry<? extends K, ? extends List<V>> entry = i.next(); final K key = entry.getKey(); final List<V> value = entry.getValue(); checkKeyValueAgreement(key, value); } for (Iterator<? extends K> i = m.keySet().iterator(); i.hasNext();) remove(i.next()); groupingList.addAll(m.values()); }
GroupingListMultiMap implements DisposableMap<K, List<V>>, ListEventListener<List<V>> { @Override public void putAll(Map<? extends K, ? extends List<V>> m) { for (Iterator<? extends Entry<? extends K, ? extends List<V>>> i = m.entrySet().iterator(); i.hasNext();) { final Entry<? extends K, ? extends List<V>> entry = i.next(); final K key = entry.getKey(); final List<V> value = entry.getValue(); checkKeyValueAgreement(key, value); } for (Iterator<? extends K> i = m.keySet().iterator(); i.hasNext();) remove(i.next()); groupingList.addAll(m.values()); } }
GroupingListMultiMap implements DisposableMap<K, List<V>>, ListEventListener<List<V>> { @Override public void putAll(Map<? extends K, ? extends List<V>> m) { for (Iterator<? extends Entry<? extends K, ? extends List<V>>> i = m.entrySet().iterator(); i.hasNext();) { final Entry<? extends K, ? extends List<V>> entry = i.next(); final K key = entry.getKey(); final List<V> value = entry.getValue(); checkKeyValueAgreement(key, value); } for (Iterator<? extends K> i = m.keySet().iterator(); i.hasNext();) remove(i.next()); groupingList.addAll(m.values()); } GroupingListMultiMap(EventList<V> source, FunctionList.Function<V, ? extends K> keyFunction, Comparator<? super K> keyGrouper); }
GroupingListMultiMap implements DisposableMap<K, List<V>>, ListEventListener<List<V>> { @Override public void putAll(Map<? extends K, ? extends List<V>> m) { for (Iterator<? extends Entry<? extends K, ? extends List<V>>> i = m.entrySet().iterator(); i.hasNext();) { final Entry<? extends K, ? extends List<V>> entry = i.next(); final K key = entry.getKey(); final List<V> value = entry.getValue(); checkKeyValueAgreement(key, value); } for (Iterator<? extends K> i = m.keySet().iterator(); i.hasNext();) remove(i.next()); groupingList.addAll(m.values()); } GroupingListMultiMap(EventList<V> source, FunctionList.Function<V, ? extends K> keyFunction, Comparator<? super K> keyGrouper); @Override void dispose(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override List<V> get(Object key); @Override List<V> put(K key, List<V> value); @Override void putAll(Map<? extends K, ? extends List<V>> m); @Override void clear(); @Override List<V> remove(Object key); @Override Collection<List<V>> values(); @Override Set<K> keySet(); @Override Set<Entry<K, List<V>>> entrySet(); @Override boolean equals(Object o); @Override int hashCode(); @Override void listChanged(ListEvent<List<V>> listChanges); }
GroupingListMultiMap implements DisposableMap<K, List<V>>, ListEventListener<List<V>> { @Override public void putAll(Map<? extends K, ? extends List<V>> m) { for (Iterator<? extends Entry<? extends K, ? extends List<V>>> i = m.entrySet().iterator(); i.hasNext();) { final Entry<? extends K, ? extends List<V>> entry = i.next(); final K key = entry.getKey(); final List<V> value = entry.getValue(); checkKeyValueAgreement(key, value); } for (Iterator<? extends K> i = m.keySet().iterator(); i.hasNext();) remove(i.next()); groupingList.addAll(m.values()); } GroupingListMultiMap(EventList<V> source, FunctionList.Function<V, ? extends K> keyFunction, Comparator<? super K> keyGrouper); @Override void dispose(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override List<V> get(Object key); @Override List<V> put(K key, List<V> value); @Override void putAll(Map<? extends K, ? extends List<V>> m); @Override void clear(); @Override List<V> remove(Object key); @Override Collection<List<V>> values(); @Override Set<K> keySet(); @Override Set<Entry<K, List<V>>> entrySet(); @Override boolean equals(Object o); @Override int hashCode(); @Override void listChanged(ListEvent<List<V>> listChanges);  }