K - the type of the Map's keys.V - the type of the Map's values.public final class ChainMap<K,V> extends AbstractMap<K,V>
ChainMap is a Map implementation that groups multiple
Maps together. Lookups sequentially walk trough all the underlying
Maps until the value for the looked up key is found. Writes and
updates only modify the first Map. Deletions are applied on all
underlying Maps. Note that only references to the input Maps
are stored, so, if one of these Maps gets updated, those changes will
also be reflected in the ChainMap. Not thread safe.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
ChainMap(Iterable<? extends Map<K,V>> maps)
Creates a new
ChainMap from the given Maps. |
ChainMap(Map<K,V>... maps)
Creates a new
ChainMap from the given Maps. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> m) |
V |
remove(Object key) |
int |
size() |
Collection<V> |
values() |
clone, equals, hashCode, toStringpublic ChainMap(Map<K,V>... maps)
ChainMap from the given Maps.maps - the input Maps.NullPointerException - if maps is null or if it
contains a null reference.IllegalArgumentException - if maps is empty.public ChainMap(Iterable<? extends Map<K,V>> maps)
ChainMap from the given Maps.maps - the input Maps.NullPointerException - if maps is null or if it
contains a null reference.IllegalArgumentException - if maps is empty.public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>containsValue in class AbstractMap<K,V>public void clear()
public Collection<V> values()
Copyright © 2012–2015. All rights reserved.