K
- the type of the keys in this mapV
- the type of the values in this mappublic class TransformedMap<K,V> extends AbstractMapDecorator<K,V> implements java.io.Serializable
Map
to transform objects that are added.
The Map put methods and Map.Entry setValue method are affected by this class. 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 TransformedMap 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 Collections.synchronizedMap(Map)
. This class may throw
exceptions when accessed by concurrent threads without synchronization.
This class is Serializable from Commons Collections 3.1.
TransformedSplitMap
,
Serialized FormModifier and Type | Method and Description |
---|---|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
put(K key,
V value)
Note that the return type is Object, rather than V as in the Map interface.
|
void |
putAll(java.util.Map<? extends K,? extends V> mapToCopy) |
static <K,V> TransformedMap<K,V> |
transformedMap(java.util.Map<K,V> map,
Transformer<? super K,? extends K> keyTransformer,
Transformer<? super V,? extends V> valueTransformer)
Factory method to create a transforming map that will transform
existing contents of the specified map.
|
static <K,V> TransformedMap<K,V> |
transformingMap(java.util.Map<K,V> map,
Transformer<? super K,? extends K> keyTransformer,
Transformer<? super V,? extends V> valueTransformer)
Factory method to create a transforming map.
|
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, remove, size, toString, values
mapIterator
public static <K,V> TransformedMap<K,V> transformingMap(java.util.Map<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(Map, Transformer, Transformer)
.
K
- the key typeV
- the value typemap
- the map to decorate, must not be nullkeyTransformer
- the transformer to use for key conversion, null means no transformationvalueTransformer
- the transformer to use for value conversion, null means no transformationjava.lang.NullPointerException
- if map is nullpublic static <K,V> TransformedMap<K,V> transformedMap(java.util.Map<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(Map, Transformer, Transformer)
.
K
- the key typeV
- the value typemap
- the map to decorate, must not be nullkeyTransformer
- the transformer to use for key conversion, null means no transformationvalueTransformer
- the transformer to use for value conversion, null means no transformationjava.lang.NullPointerException
- if map is nullpublic V put(K key, V value)
Put
put
in interface java.util.Map<K,V>
put
in interface Put<K,V>
put
in class AbstractMapDecorator<K,V>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keykey
, or
null
if there was no mapping for key
.
(A null
return can also indicate that the map
previously associated null
with key
,
if the implementation supports null
values.)Map.put(Object, Object)
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in interface java.util.Map<K,V>
entrySet
in interface Get<K,V>
entrySet
in class AbstractMapDecorator<K,V>
Map.entrySet()
Copyright © 2010 - 2020 Adobe. All Rights Reserved