public class HashMapWrapper<K,V>
extends java.util.HashMap<K,V>
HashMapWrapper
is a HashMap
that "wraps" another
HashMap
. All mappings in this map "override" any mappings in
the wrapped map. Many HashMapWrappers
can be used to wrap a
single map, to avoid the need to clone a single map multiple times. This
wrapper doesn't necessarily override all Map
methods.Constructor | Description |
---|---|
HashMapWrapper(java.util.Map<K,V> otherMap) |
Constructs a
HashMapWrapper that wraps the given Map . |
Modifier and Type | Method | Description |
---|---|---|
void |
clear() |
Clears all entries in this map and in the wrapped map.
|
boolean |
containsKey(java.lang.Object key) |
Looks in this map, and if not found, looks in the wrapped map.
|
boolean |
containsValue(java.lang.Object value) |
Looks in this map, and if not found, looks in the wrapped map.
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
Returns a
Set of all entries in this map and the wrapped
map, with this map overriding any entries in the wrapped map. |
V |
get(java.lang.Object key) |
Returns the value from this map to which the key is mapped, or from the
wrapped map if not present in this map.
|
boolean |
isEmpty() |
Returns
true if this map and the wrapped map are both empty. |
java.util.Set<K> |
keySet() |
Returns a
Set of all keys in this map and the wrapped
map, with this map overriding any keys in the wrapped map. |
V |
put(K key,
V value) |
Maps the given key to the given value in this map, never the wrapped map.
|
void |
putAll(java.util.Map<? extends K,? extends V> map) |
Puts all entries from the given map into this map, never the wrapped map.
|
V |
remove(java.lang.Object key) |
Removes the entry associated with this key from this map, never the
wrapped map.
|
int |
size() |
Returns the number of mappings in this map unioned with the wrapped map.
|
java.util.Collection<V> |
values() |
Returns a
Collection of all values in this map and the
wrapped map, with this map overriding any values in the wrapped map with
the same key. |
clone, compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public void clear()
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Set
of all entries in this map and the wrapped
map, with this map overriding any entries in the wrapped map. Changes
to the returned Set
do not write through to this map.public V get(java.lang.Object key)
public boolean isEmpty()
true
if this map and the wrapped map are both empty.public java.util.Set<K> keySet()
Set
of all keys in this map and the wrapped
map, with this map overriding any keys in the wrapped map. Changes
to the returned Set
do not write through to this map.public V put(K key, V value)
public void putAll(java.util.Map<? extends K,? extends V> map)
public V remove(java.lang.Object key)
public int size()
public java.util.Collection<V> values()
Collection
of all values in this map and the
wrapped map, with this map overriding any values in the wrapped map with
the same key. Changes to the returned Collection
do not
write through to this map.Copyright © 2012–2018 Jett Team. All rights reserved.