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 java.. This class may throw
exceptions when accessed by concurrent threads without synchronization.
This class is Serializable from Commons Collections 3.1.
org.apache.commons.collections4.splitmap.TransformedSplitMap
| Modifier and Type | Field and Description |
|---|---|
| protected final Transformer | keyTransformer
The transformer to use for the key |
| private static final long | serialVersionUID
Serialization version |
| protected final Transformer | valueTransformer
The transformer to use for the value |
| Access | Constructor and Description |
|---|---|
| protected | TransformedMap(final Map<K, V>
the map to decorate, must not be null map, final Transformer<? super K, ? extends K> the transformer to use for key conversion, null means no conversion keyTransformer, final Transformer<? super V, ? extends V> the transformer to use for value conversion, null means no conversion valueTransformer)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| protected V | Returns: the transformed valuethe value to transform value)Implements abstract org. setValue.
|
| protected boolean | Returns: true if a value transformer is in useOverrides org. |
| 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)Overrides org. Implements java. |
| public void | putAll(Map<? extends K, ? extends V>
mappings to be stored in this map mapToCopy)Overrides org. Implements java. |
| private void | |
| public static < the key type K, the value type V> TransformedMap | Returns: a new transformed mapthe map to decorate, must not be null map, final Transformer<? super K, ? extends K> the transformer to use for key conversion, null means no transformation keyTransformer, final Transformer<? super V, ? extends V> the transformer to use for value conversion, null means no transformation valueTransformer)Factory method to create a transforming map that will transform existing contents of the specified map. |
| public static < the key type K, the value type V> TransformedMap | Returns: a new transformed mapthe map to decorate, must not be null map, final Transformer<? super K, ? extends K> the transformer to use for key conversion, null means no transformation keyTransformer, final Transformer<? super V, ? extends V> the transformer to use for value conversion, null means no transformation valueTransformer)Factory method to create a transforming map. |
| protected K | |
| protected Map | Returns: the transformed objectthe map to transform map)Transforms a map. |
| protected V | Returns: the transformed objectthe object to transform object)Transforms a value. |
| private void |
| keyTransformer | back to summary |
|---|---|
| protected final Transformer<? super K, ? extends K> keyTransformer The transformer to use for the key | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version | |
| valueTransformer | back to summary |
|---|---|
| protected final Transformer<? super V, ? extends V> valueTransformer The transformer to use for the value | |
| TransformedMap | back to summary |
|---|---|
| protected TransformedMap(final Map<K, V> map, final Transformer<? super K, ? extends K> keyTransformer, final Transformer<? super V, ? extends V> valueTransformer) Constructor that wraps (not copies). If there are any elements already in the collection being decorated, they are NOT transformed.
| |
| checkSetValue | back to summary |
|---|---|
| protected V checkSetValue(final V value) Implements abstract org. Override to transform the value when using
| |
| isSetValueChecking | back to summary |
|---|---|
| protected boolean isSetValueChecking() Overrides org. Override to only return true when there is a value transformer.
| |
| put | back to summary |
|---|---|
| public V put(K key, V value) Overrides org. 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> mapToCopy) Overrides org. 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 | |
| readObject | back to summary |
|---|---|
| private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException Read the map in using a custom routine.
| |
| transformedMap | back to summary |
|---|---|
| public static <K, V> TransformedMap Factory method to create a transforming map that will transform existing contents of the specified map.
If there are any elements already in the map being decorated, they
will be transformed by this method.
Contrast this with
| |
| transformingMap | back to summary |
|---|---|
| public static <K, V> TransformedMap Factory method to create a transforming map.
If there are any elements already in the map being decorated, they
are NOT transformed.
Contrast this with
| |
| transformKey | back to summary |
|---|---|
| protected K transformKey(final K object) Transforms a key. The transformer itself may throw an exception if necessary.
| |
| transformMap | back to summary |
|---|---|
| protected Map Transforms a map. The transformer itself may throw an exception if necessary.
| |
| transformValue | back to summary |
|---|---|
| protected V transformValue(final V object) Transforms a value. The transformer itself may throw an exception if necessary.
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(final ObjectOutputStream out) throws IOException Write the map out using a custom routine.
| |