Changes made to this map will actually be made on the decorated map. Add and remove operations require the use of a pluggable strategy. If no strategy is provided then add and remove are unsupported.
Note that CompositeMap is not synchronized and is not thread-safe.
If you wish to use this map from multiple threads concurrently, you must use
appropriate synchronization. The simplest approach is to wrap this map
using java.. This class may throw
exceptions when accessed by concurrent threads without synchronization.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | CompositeMap.MapMutator<
the type of the keys in the map K, the type of the values in the map V>This interface allows definition for all of the indeterminate mutators in a CompositeMap, as well as providing a hook for callbacks on key collisions. |
| Modifier and Type | Field and Description |
|---|---|
| private Map | composite
Array of all maps in the composite |
| private CompositeMap. | mutator
Handle mutation operations |
| private static final long | serialVersionUID
Serialization version |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CompositeMap(final Map<K, V>
the first Map to be composited one, final Map<K, V> the second Map to be composited two)Create a new CompositeMap with two composited Map instances. |
| public | CompositeMap(final Map<K, V>
the first Map to be composited one, final Map<K, V> the second Map to be composited two, final CompositeMap.MapMutator to be used for mutation operations mutatorCreate a new CompositeMap with two composited Map instances. |
| public | CompositeMap(final Map<K, V>...
the Maps to be composited composite)Create a new CompositeMap which composites all of the Map instances in the argument. |
| public | CompositeMap(final Map<K, V>[]
Maps to be composited composite, final CompositeMap.MapMutator to be used for mutation operations mutatorCreate a new CompositeMap which composites all of the Map instances in the argument. |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | addComposited(final Map<K, V>
the Map to be added to the composite map)Add an additional Map to the composite. |
| public void | clear()
Implements java. clear() on all composited Maps.
|
| public boolean | Returns: true if this map contains a mapping for the specified
key.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 | Returns: true if this map maps one or more keys to the
specified value.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.
|
| public Set | Returns: a set view of the mappings contained in this map.Implements java. |
| public boolean | Returns: true if the maps are equalthe object to compare to obj)Overrides java. Implements java. |
| public V | Returns: the value to which this map maps the specified key, ornull if the map contains no mapping for this key.key whose associated value is to be returned. key)Implements java. |
| public int | hashCode()
Overrides java. Implements java. |
| public boolean | Returns: true if this map contains no key-value mappings.Implements java. true if this map contains no key-value mappings.
|
| public Set | Returns: a set view of the keys contained in this map.Implements java. |
| public V | Returns: previous value associated with specified key, ornull
if there was no mapping for key. A null return can
also indicate that the map previously associated null
with the specified key, if the implementation supports
null values.key with which the specified value is to be associated. key, final V value to be associated with the specified key. value)Implements java. |
| public void | putAll(final Map<? extends K, ? extends V>
Mappings to be stored in this map. map)Implements java. |
| public V | Returns: previous value associated with specified key, ornull
if there was no mapping for key.key whose mapping is to be removed from the map. key)Implements java. |
| public synchronized Map | Returns: The removed Map ornull if map is not in the compositethe Map to be removed from the composite map)Remove a Map from the composite. |
| public void | setMutator(final CompositeMap.
the MapMutator to be used for mutation delegation mutatorSpecify the MapMutator to be used by mutation operations. |
| public int | Returns: the number of key-value mappings in this map.Implements java. |
| public Collection | Returns: a collection view of the values contained in this map.Implements java. |
| composite | back to summary |
|---|---|
| private Map<K, V>[] composite Array of all maps in the composite | |
| mutator | back to summary |
|---|---|
| private CompositeMap. Handle mutation operations | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version | |
| CompositeMap | back to summary |
|---|---|
| public CompositeMap() Create a new, empty, CompositeMap.
| |
| CompositeMap | back to summary |
|---|---|
| public CompositeMap(final Map<K, V> one, final Map<K, V> two) Create a new CompositeMap with two composited Map instances.
| |
| CompositeMap | back to summary |
|---|---|
| public CompositeMap(final Map<K, V> one, final Map<K, V> two, final CompositeMap. Create a new CompositeMap with two composited Map instances.
| |
| CompositeMap | back to summary |
|---|---|
| public CompositeMap(final Map<K, V>... composite) Create a new CompositeMap which composites all of the Map instances in the argument. It copies the argument array, it does not use it directly.
| |
| CompositeMap | back to summary |
|---|---|
| public CompositeMap(final Map<K, V>[] composite, final CompositeMap. Create a new CompositeMap which composites all of the Map instances in the argument. It copies the argument array, it does not use it directly.
| |
| addComposited | back to summary |
|---|---|
| public synchronized void addComposited(final Map<K, V> map) throws IllegalArgumentException Add an additional Map to the composite.
| |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Calls
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(final Object key) Implements java. Returns
| |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(final Object value) Implements java. Returns
| |
| entrySet | back to summary |
|---|---|
| public Set Implements java. Returns a set view of the mappings contained in this map. Each element
in the returned set is a
This implementation returns a
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Implements java. Checks if this Map equals another as per the Map specification. | |
| get | back to summary |
|---|---|
| public V get(final Object key) Implements java. Returns the value to which this map maps the specified key. Returns
More formally, if this map contains a mapping from a key
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Gets a hash code for the Map as per the Map specification.
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. Returns
| |
| keySet | back to summary |
|---|---|
| public Set Implements java. Returns a set view of the keys contained in this map. The set is
backed by the map, so changes to the map are reflected in the set, and
vice-versa. If the map is modified while an iteration over the set is
in progress, the results of the iteration are undefined. The set
supports element removal, which removes the corresponding mapping from
the map, via the
This implementation returns a | |
| put | back to summary |
|---|---|
| public V put(final K key, final V value) Implements java. Associates the specified value with the specified key in this map
(optional operation). If the map previously contained a mapping for
this key, the old value is replaced by the specified value. (A map
| |
| putAll | back to summary |
|---|---|
| public void putAll(final Map<? extends K, ? extends V> map) Implements 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(final Object key) Implements java. Removes the mapping for this 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 the map previously associated the key, or
| |
| removeComposited | back to summary |
|---|---|
| public synchronized Map Remove a Map from the composite.
| |
| setMutator | back to summary |
|---|---|
| public void setMutator(final CompositeMap. Specify the MapMutator to be used by mutation operations.
| |
| size | back to summary |
|---|---|
| public int size() Implements java. Returns the number of key-value mappings in this map. If the
map contains more than
| |
| values | back to summary |
|---|---|
| public Collection Implements java. Returns a collection view of the values contained in this map. The
collection is backed by the map, so changes to the map are reflected in
the collection, and vice-versa. If the map is modified while an
iteration over the collection is in progress, the results of the
iteration are undefined. The collection supports element removal,
which removes the corresponding mapping from the map, via the
| |
| Modifier and Type | Method and Description |
|---|---|
| public V | Returns: previous value associated with specified key, ornull
if there was no mapping for key. A null return can
also indicate that the map previously associated null
with the specified key, if the implementation supports
null values.the CompositeMap which is being modified map, Map<K, V>[] array of Maps in the CompositeMap being modified composited, K key with which the specified value is to be associated. key, V value to be associated with the specified key. value)Called when the CompositeMap.put() method is invoked. |
| public void | putAll(CompositeMap<K, V>
the CompositeMap which is being modified map, Map<K, V>[] array of Maps in the CompositeMap being modified composited, Map<? extends K, ? extends V> Mappings to be stored in this CompositeMap mapToAdd)Called when the CompositeMap.putAll() method is invoked. |
| public void | resolveCollision(CompositeMap<K, V>
the CompositeMap with the collision composite, Map<K, V> the Map already in the composite which contains the
offending key existing, Map<K, V> the Map being added added, Collection<K> the intersection of the keysets of the existing and added maps intersect)Called when adding a new Composited Map results in a key collision. |
| put | back to summary |
|---|---|
| public V put(CompositeMap<K, V> map, Map<K, V>[] composited, K key, V value) Called when the CompositeMap.put() method is invoked.
| |
| putAll | back to summary |
|---|---|
| public void putAll(CompositeMap<K, V> map, Map<K, V>[] composited, Map<? extends K, ? extends V> mapToAdd) Called when the CompositeMap.putAll() method is invoked.
| |
| resolveCollision | back to summary |
|---|---|
| public void resolveCollision(CompositeMap<K, V> composite, Map<K, V> existing, Map<K, V> added, Collection<K> intersect) Called when adding a new Composited Map results in a key collision.
| |