@Test public void testPutAll() { final Map<String, String> firstMap = nonEmptyCopyOnWriteMap(); final Map<String, String> secondMap = new HashMap<>(); secondMap.put(NEW_KEY, NEW_VALUE); firstMap.putAll(secondMap); assertEquals(4, firstMap.size()); assertEquals(NEW_VALUE, firstMap.get(NEW_KEY)); }
@Override public synchronized void putAll(Map<? extends K, ? extends V> m) { final Map<K, V> delegate = new HashMap<>(this.delegate); for(Entry<? extends K, ? extends V> e : m.entrySet()) { delegate.put(e.getKey(), e.getValue()); } this.delegate = delegate; }
CopyOnWriteMap implements ConcurrentMap<K, V> { @Override public synchronized void putAll(Map<? extends K, ? extends V> m) { final Map<K, V> delegate = new HashMap<>(this.delegate); for(Entry<? extends K, ? extends V> e : m.entrySet()) { delegate.put(e.getKey(), e.getValue()); } this.delegate = delegate; } }
CopyOnWriteMap implements ConcurrentMap<K, V> { @Override public synchronized void putAll(Map<? extends K, ? extends V> m) { final Map<K, V> delegate = new HashMap<>(this.delegate); for(Entry<? extends K, ? extends V> e : m.entrySet()) { delegate.put(e.getKey(), e.getValue()); } this.delegate = delegate; } CopyOnWriteMap();   CopyOnWriteMap(final Map<K, V> existing); }
CopyOnWriteMap implements ConcurrentMap<K, V> { @Override public synchronized void putAll(Map<? extends K, ? extends V> m) { final Map<K, V> delegate = new HashMap<>(this.delegate); for(Entry<? extends K, ? extends V> e : m.entrySet()) { delegate.put(e.getKey(), e.getValue()); } this.delegate = delegate; } CopyOnWriteMap();   CopyOnWriteMap(final Map<K, V> existing); @Override synchronized V putIfAbsent(K key, V value); @Override synchronized boolean remove(Object key, Object value); @Override synchronized boolean replace(K key, V oldValue, V newValue); @Override synchronized V replace(K key, V value); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override synchronized V put(K key, V value); @Override synchronized V remove(Object key); @Override synchronized void putAll(Map<? extends K, ? extends V> m); @Override synchronized void clear(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Entry<K, V>> entrySet(); }
CopyOnWriteMap implements ConcurrentMap<K, V> { @Override public synchronized void putAll(Map<? extends K, ? extends V> m) { final Map<K, V> delegate = new HashMap<>(this.delegate); for(Entry<? extends K, ? extends V> e : m.entrySet()) { delegate.put(e.getKey(), e.getValue()); } this.delegate = delegate; } CopyOnWriteMap();   CopyOnWriteMap(final Map<K, V> existing); @Override synchronized V putIfAbsent(K key, V value); @Override synchronized boolean remove(Object key, Object value); @Override synchronized boolean replace(K key, V oldValue, V newValue); @Override synchronized V replace(K key, V value); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override synchronized V put(K key, V value); @Override synchronized V remove(Object key); @Override synchronized void putAll(Map<? extends K, ? extends V> m); @Override synchronized void clear(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Entry<K, V>> entrySet();  }