Warning
The methods of ForwardingMap forward indiscriminately to the
methods of the delegate. For example, overriding put alone will not change the
behavior of putAll, which can lead to unexpected behavior. In this case, you should
override putAll as well, either providing your own implementation, or delegating to the
provided standardPutAll method.
default method warning: This class does not forward calls to default methods. Instead, it inherits their default implementations. When those implementations
invoke methods, they invoke methods on the ForwardingMap.
Each of the standard methods, where appropriate, use Objects#equal to test
equality for both keys and values. This may not be the desired behavior for map implementations
that use non-standard notions of key equality, such as a SortedMap whose comparator is
not consistent with equals.
The standard methods and the collection views they return are not guaranteed to be
thread-safe, even when all of the methods that they depend on are thread-safe.
| Modifier and Type | Class and Description |
|---|---|
| protected abstract class | ForwardingMap.StandardEntrySet
A sensible implementation of |
| protected class | ForwardingMap.StandardKeySet
A sensible implementation of |
| protected class | ForwardingMap.StandardValues
A sensible implementation of |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements java. |
| public boolean | containsKey(Object
key whose presence in this map is to be tested key)Implements java. true if this map contains a mapping for the specified
key.
|
| public boolean | containsValue(Object
value whose presence in this map is to be tested value)Implements java. true if this map maps one or more keys to the
specified value.
|
| protected abstract Map | delegate()
Implements abstract com. |
| public Set | entrySet()
Implements java. Set view of the mappings contained in this map.
|
| public boolean | equals(Object
object to be compared for equality with this map object)Overrides java. Implements java. |
| public V | get(Object
the key whose associated value is to be returned key)Implements java. null if this map contains no mapping for the key.
|
| public int | hashCode()
Overrides java. Implements java. |
| public boolean | |
| public Set | |
| public V | put(K
key with which the specified value is to be associated key, V value to be associated with the specified key value)Implements java. |
| public void | putAll(Map<? extends K, ? extends V>
mappings to be stored in this map map)Implements java. |
| public V | remove(Object
key whose mapping is to be removed from the map key)Implements java. |
| public int | |
| protected void | |
| protected boolean | standardContainsKey(Object key)
A sensible, albeit inefficient, definition of |
| protected boolean | standardContainsValue(Object value)
A sensible definition of |
| protected boolean | standardEquals(Object object)
A sensible definition of |
| protected int | |
| protected boolean | |
| protected void | standardPutAll(Map<? extends K, ? extends V> map)
A sensible definition of |
| protected V | standardRemove(Object key)
A sensible, albeit inefficient, definition of |
| protected String | |
| public Collection | values()
Implements java. Collection view of the values contained in this map.
|
| ForwardingMap | back to summary |
|---|---|
| protected ForwardingMap() Constructor for use by subclasses. | |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Doc from java. Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object key) Implements java. Doc from java. Returns | |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) Implements java. Doc from java. Returns | |
| delegate | back to summary |
|---|---|
| protected abstract Map Implements abstract com. Doc from com. Returns the backing delegate instance that methods are forwarded to. Abstract subclasses
generally override this method with an abstract method that has a more specific return type,
such as
| |
| entrySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a | |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Implements java. Doc from java. Compares the specified object with this map for equality. Returns
| |
| get | back to summary |
|---|---|
| public V get(Object key) Implements java. Doc from java. Returns the value to which the specified key is mapped,
or More formally, if this map contains a mapping from a key
If this map permits null values, then a return value of
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this map. The hash code of a map is
defined to be the sum of the hash codes of each entry in the map's
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements java. Doc from java. Returns
| |
| keySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a | |
| put | back to summary |
|---|---|
| public V put(K key, V value) Implements java. Doc from java. Associates the specified value with the specified key in this map
(optional operation). If the map previously contained a mapping for
the key, the old value is replaced by the specified value. (A map
| |
| putAll | back to summary |
|---|---|
| public void putAll(Map<? extends K, ? extends V> map) Implements java. Doc from java. Copies all of the mappings from the specified map to this map
(optional operation). The effect of this call is equivalent to that
of calling | |
| remove | back to summary |
|---|---|
| public V remove(Object key) Implements java. Doc from java. Removes the mapping for a key from this map if it is present
(optional operation). More formally, if this map contains a mapping
from key Returns the value to which this map previously associated the key,
or If this map permits null values, then a return value of
The map will not contain a mapping for the specified key once the call returns.
| |
| size | back to summary |
|---|---|
| public int size() Implements java. Doc from java. Returns the number of key-value mappings in this map. If the
map contains more than
| |
| standardClear | back to summary |
|---|---|
| protected void standardClear() A sensible definition of
| |
| standardContainsKey | back to summary |
|---|---|
| protected boolean standardContainsKey(Object key) A sensible, albeit inefficient, definition of
| |
| standardContainsValue | back to summary |
|---|---|
| protected boolean standardContainsValue(Object value) A sensible definition of
| |
| standardEquals | back to summary |
|---|---|
| protected boolean standardEquals(Object object) A sensible definition of
| |
| standardHashCode | back to summary |
|---|---|
| protected int standardHashCode() A sensible definition of
| |
| standardIsEmpty | back to summary |
|---|---|
| protected boolean standardIsEmpty() A sensible definition of
| |
| standardPutAll | back to summary |
|---|---|
| protected void standardPutAll(Map<? extends K, ? extends V> map) A sensible definition of
| |
| standardRemove | back to summary |
|---|---|
| protected V standardRemove(Object key) A sensible, albeit inefficient, definition of Alternately, you may wish to override
| |
| standardToString | back to summary |
|---|---|
| protected String standardToString() A sensible definition of
| |
| values | back to summary |
|---|---|
| public Collection Implements java. Doc from java. Returns a
| |
Map#entrySet in terms of the following methods: ForwardingMap#clear, ForwardingMap#containsKey, ForwardingMap#get, ForwardingMap#isEmpty, ForwardingMap#remove, and ForwardingMap#size. In many
cases, you may wish to override entrySet to forward to this implementation or a
subclass thereof.
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Map |
| StandardEntrySet | back to summary |
|---|---|
| protected StandardEntrySet() Constructor for use by subclasses. | |
| map | back to summary |
|---|---|
| pack-priv Map Implements abstract com.
| |
Map#keySet in terms of the following methods: ForwardingMap#clear, ForwardingMap#containsKey, ForwardingMap#isEmpty, ForwardingMap#remove, ForwardingMap#size, and the Set#iterator method of
ForwardingMap#entrySet. In many cases, you may wish to override ForwardingMap#keySet to forward to this implementation or a subclass thereof.
| Access | Constructor and Description |
|---|---|
| public |
| StandardKeySet | back to summary |
|---|---|
| public StandardKeySet() Constructor for use by subclasses. | |
Map#values in terms of the following methods: ForwardingMap#clear, ForwardingMap#containsValue, ForwardingMap#isEmpty,
ForwardingMap#size, and the Set#iterator method of ForwardingMap#entrySet. In many cases, you may wish to override ForwardingMap#values
to forward to this implementation or a subclass thereof.
| Access | Constructor and Description |
|---|---|
| public |
| StandardValues | back to summary |
|---|---|
| public StandardValues() Constructor for use by subclasses. | |