abstract class AbstractInputCheckedMapDecorator extends AbstractMapDecorator
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.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
AbstractInputCheckedMapDecorator.EntrySet
Implementation of an entry set that checks additions via setValue.
|
(package private) static class |
AbstractInputCheckedMapDecorator.EntrySetIterator
Implementation of an entry set iterator that checks additions via setValue.
|
(package private) static class |
AbstractInputCheckedMapDecorator.MapEntry
Implementation of a map entry that checks additions via setValue.
|
map
Modifier | Constructor and Description |
---|---|
protected |
AbstractInputCheckedMapDecorator()
Constructor only used in deserialization, do not use otherwise.
|
protected |
AbstractInputCheckedMapDecorator(java.util.Map map)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
protected abstract java.lang.Object |
checkSetValue(java.lang.Object value)
Hook method called when a value is being set using
setValue . |
java.util.Set |
entrySet() |
protected boolean |
isSetValueChecking()
Hook method called to determine if
checkSetValue has any effect. |
clear, containsKey, containsValue, equals, get, getMap, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
protected AbstractInputCheckedMapDecorator()
protected AbstractInputCheckedMapDecorator(java.util.Map map)
map
- the map to decorate, must not be nulljava.lang.IllegalArgumentException
- if map is nullprotected abstract java.lang.Object checkSetValue(java.lang.Object value)
setValue
.
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.
value
- the value to checkjava.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 invalidprotected boolean isSetValueChecking()
checkSetValue
has any effect.
An implementation should return false if the checkSetValue
method
has no effect as this optimises the implementation.
This implementation returns true
.
public java.util.Set entrySet()
entrySet
in interface java.util.Map
entrySet
in class AbstractMapDecorator