Decorates another {@link 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 {@link java.util.Collections#synchronizedMap(Map)}. This class may throw exceptions when accessed by concurrent threads without synchronization.
The "put" and "get" type constraints of this class are mutually independent; contrast with {@link org.apache.commons.collections4.map.TransformedMap} which,by virtue of its implementing {@link Map}<K, V>, must be constructed in such a way that its read and write parameters are generalized to a common (super-)type. In practice this would often mean >Object, Object>
, defeating much of the usefulness of having parameterized types.
On the downside, this class is not drop-in compatible with {@link java.util.Map}but is intended to be worked with either directly or by {@link Put} and{@link org.apache.commons.collections4.Get Get} generalizations.
@since 4.0
@version $Id: TransformedSplitMap.java 1491944 2013-06-11 20:29:22Z tn $
@see org.apache.commons.collections4.SplitMapUtils#readableMap(Get)
@see org.apache.commons.collections4.SplitMapUtils#writableMap(Put)