public class TransformedMultiValuedMap<K,V> extends AbstractMultiValuedMapDecorator<K ,V>
MultiValuedMap to transform objects that are added.
This class affects the MultiValuedMap put methods. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.
Note that TransformedMultiValuedMap is not synchronized and is not thread-safe.
| Modifier | Constructor and Description |
|---|---|
protected |
TransformedMultiValuedMap(MultiValuedMap
Constructor that wraps (not copies).
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
put(K key, V value)
Adds a key-value mapping to this multi-valued map.
|
boolean |
putAll(K key, Iterable
Adds a mapping to the specified key for all values contained in the given Iterable.
|
boolean |
putAll(Map
Copies all mappings from the specified map to this multi-valued map (optional operation).
|
boolean |
putAll(MultiValuedMap
Copies all mappings from the specified map to this multi-valued map (optional operation).
|
static <K |
transformedMap(MultiValuedMap
Factory method to create a transforming MultiValuedMap that will transform existing contents of the specified map.
|
static <K |
transformingMap(MultiValuedMap
Factory method to create a transforming MultiValuedMap.
|
protected K |
transformKey(K object)
Transforms a key.
|
protected V |
transformValue(V object)
Transforms a value.
|
asMap, clear, containsKey, containsMapping, containsValue, decorated, entries, equals, get, hashCode, isEmpty, keys, keySet, mapIterator, remove, removeMapping, size, toString, valuesprotected TransformedMultiValuedMap(MultiValuedMap<K ,V> map, Transformer <? super K ,? extends K> keyTransformer, Transformer <? super V ,? extends V> valueTransformer)
If there are any elements already in the collection being decorated, they are NOT transformed.
map - the MultiValuedMap to decorate, may not be null
keyTransformer - the transformer to use for key conversion, null means no conversion
valueTransformer - the transformer to use for value conversion, null means no conversion
NullPointerException - if map is null
public static <K,V> TransformedMultiValuedMap <K ,V> transformingMap(MultiValuedMap <K ,V> map, Transformer <? super K ,? extends K> keyTransformer, Transformer <? super V ,? extends V> valueTransformer)
If there are any elements already in the map being decorated, they are NOT transformed. Contrast this with transformedMap(MultiValuedMap, Transformer, Transformer).
K - the key type
V - the value type
map - the MultiValuedMap to decorate, may not be null
keyTransformer - the transformer to use for key conversion, null means no conversion
valueTransformer - the transformer to use for value conversion, null means no conversion
NullPointerException - if map is null
public static <K,V> TransformedMultiValuedMap <K ,V> transformedMap(MultiValuedMap <K ,V> map, Transformer <? super K ,? extends K> keyTransformer, Transformer <? super V ,? extends V> valueTransformer)
If there are any elements already in the map being decorated, they will be transformed by this method. Contrast this with transformingMap(MultiValuedMap, Transformer, Transformer).
K - the key type
V - the value type
map - the MultiValuedMap to decorate, may not be null
keyTransformer - the transformer to use for key conversion, null means no conversion
valueTransformer - the transformer to use for value conversion, null means no conversion
NullPointerException - if map is null
protected K transformKey(K object)
The transformer itself may throw an exception if necessary.
object - the object to transform
protected V transformValue(V object)
The transformer itself may throw an exception if necessary.
object - the object to transform
public boolean put(K key, V value)
MultiValuedMap
Unlike a normal Map the previous value is not replaced. Instead the new value is added to the collection stored against the key. Depending on the collection type used, duplicate key-value mappings may be allowed.
The method will return true if the size of the multi-valued map has been increased because of this operation.
put in interface
MultiValuedMap<K,V>
put in class
AbstractMultiValuedMapDecorator<K,V>
key - the key to store against
value - the value to add to the collection at the key
public boolean putAll(K key, Iterable<? extends V> values)
MultiValuedMap
putAll in interface
MultiValuedMap<K,V>
putAll in class
AbstractMultiValuedMapDecorator<K,V>
key - the key to store against
values - the values to add to the collection at the key, may not be null
public boolean putAll(Map<? extends K ,? extends V> map)
MultiValuedMap
The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map.
The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
putAll in interface
MultiValuedMap<K,V>
putAll in class
AbstractMultiValuedMapDecorator<K,V>
map - mappings to be stored in this map, may not be null
public boolean putAll(MultiValuedMap<? extends K ,? extends V> map)
MultiValuedMap
The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map.
The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
putAll in interface
MultiValuedMap<K,V>
putAll in class
AbstractMultiValuedMapDecorator<K,V>
map - mappings to be stored in this map, may not be null