public class ChainedMap extends Object implements Map
Map which provides a merged view of a defaults map with an overrides map.
Although this can be used as a map for most purposes, methods which return live views of the keys or values in the
map only take into account the overrides, not the defaults.| Constructor and Description |
|---|
ChainedMap(Map defaults)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear all override key-value pairs.
|
boolean |
containsKey(Object key)
Check if a key has a defined value.
|
boolean |
containsValue(Object value)
Check if a value is present.
|
Set |
entrySet()
Get the set of entries.
|
Object |
get(Object key)
Get value for key.
|
boolean |
isEmpty()
Check if no overrides are defined.
|
Set |
keySet()
Get the set of keys.
|
Object |
put(Object key,
Object value)
Set an override value.
|
void |
putAll(Map map)
Add all key-value pairs from another map into the overrides map.
|
Object |
remove(Object key)
Remove a key-value pair.
|
int |
size()
Get the number of entries in the map.
|
Collection |
values()
Get the values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic ChainedMap(Map defaults)
defaults - map providing defaults for keys not set directlypublic void clear()
public boolean containsKey(Object key)
true if the key is present in the overrides map
with a non-null value, or if the key is not present in the overrides map but is present in the defaults map.containsKey in interface Mapkey - Keytrue if key defined, false if notpublic boolean containsValue(Object value)
containsValue in interface Mapvalue - to checktrue if value present as an override, false if notpublic Set entrySet()
public Object get(Object key)
public boolean isEmpty()
public Set keySet()
public Object put(Object key, Object value)
public void putAll(Map map)
public Object remove(Object key)
public int size()
public Collection values()
Copyright © 2005–2016 jibx.org. All rights reserved.