Decorates another
Map
to validate that additions match a specified predicate.
This map exists to provide validation for the decorated map. It is normally created to decorate an empty map. If an object cannot be added to the map, an IllegalArgumentException is thrown.
One usage would be to ensure that no null keys are added to the map.
Map map = PredicatedSet.decorate(new HashMap(), NotNullPredicate.INSTANCE, null);
Note that PredicatedMap 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.
This class is Serializable from Commons Collections 3.1.
@since 3.0
@version $Id: PredicatedMap.java 1479407 2013-05-05 22:07:53Z tn $