Class AbstractInputCheckedMapDecorator
- java.lang.Object
-
- org.apache.commons.collections.map.AbstractMapDecorator
-
- org.apache.commons.collections.map.AbstractInputCheckedMapDecorator
-
- All Implemented Interfaces:
java.util.Map
- Direct Known Subclasses:
PredicatedMap,TransformedMap
abstract class AbstractInputCheckedMapDecorator extends AbstractMapDecorator
An abstract base class that simplifies the task of creating map decorators.The Map API is very difficult to decorate correctly, and involves implementing lots of different classes. This class exists to provide a simpler API.
Special hook methods are provided that are called when objects are added to the map. By overriding these methods, the input can be validated or manipulated. In addition to the main map methods, the entrySet is also affected, which is the hardest part of writing map implementations.
This class is package-scoped, and may be withdrawn or replaced in future versions of Commons Collections.
- Since:
- Commons Collections 3.1
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classAbstractInputCheckedMapDecorator.EntrySetImplementation of an entry set that checks additions via setValue.(package private) static classAbstractInputCheckedMapDecorator.EntrySetIteratorImplementation of an entry set iterator that checks additions via setValue.(package private) static classAbstractInputCheckedMapDecorator.MapEntryImplementation of a map entry that checks additions via setValue.
-
Field Summary
-
Fields inherited from class org.apache.commons.collections.map.AbstractMapDecorator
map
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractInputCheckedMapDecorator()Constructor only used in deserialization, do not use otherwise.protectedAbstractInputCheckedMapDecorator(java.util.Map map)Constructor that wraps (not copies).
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.ObjectcheckSetValue(java.lang.Object value)Hook method called when a value is being set usingsetValue.java.util.SetentrySet()protected booleanisSetValueChecking()Hook method called to determine ifcheckSetValuehas any effect.-
Methods inherited from class org.apache.commons.collections.map.AbstractMapDecorator
clear, containsKey, containsValue, equals, get, getMap, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
-
-
-
-
Constructor Detail
-
AbstractInputCheckedMapDecorator
protected AbstractInputCheckedMapDecorator()
Constructor only used in deserialization, do not use otherwise.
-
AbstractInputCheckedMapDecorator
protected AbstractInputCheckedMapDecorator(java.util.Map map)
Constructor that wraps (not copies).- Parameters:
map- the map to decorate, must not be null- Throws:
java.lang.IllegalArgumentException- if map is null
-
-
Method Detail
-
checkSetValue
protected abstract java.lang.Object checkSetValue(java.lang.Object value)
Hook method called when a value is being set usingsetValue.An implementation may validate the value and throw an exception or it may transform the value into another object.
This implementation returns the input value.
- Parameters:
value- the value to check- Throws:
java.lang.UnsupportedOperationException- if the map may not be changed by setValuejava.lang.IllegalArgumentException- if the specified value is invalidjava.lang.ClassCastException- if the class of the specified value is invalidjava.lang.NullPointerException- if the specified value is null and nulls are invalid
-
isSetValueChecking
protected boolean isSetValueChecking()
Hook method called to determine ifcheckSetValuehas any effect.An implementation should return false if the
checkSetValuemethod has no effect as this optimises the implementation.This implementation returns
true.- Returns:
- true always
-
entrySet
public java.util.Set entrySet()
- Specified by:
entrySetin interfacejava.util.Map- Overrides:
entrySetin classAbstractMapDecorator
-
-