net.sf.molae.pipe.filter
Class KeyFilteredMap
java.lang.Object
|
+--java.util.AbstractMap
|
+--net.sf.molae.pipe.basic.AbstractMapWithSet
|
+--net.sf.molae.pipe.filter.KeyFilteredMap
- All Implemented Interfaces:
- Map
- public final class KeyFilteredMap
- extends AbstractMapWithSet
Implements a map that contains all entries of a base map
of which the key matches a filter condition.
|
Method Summary |
protected void |
assertRange(Object o)
Checks if the specified object fulfils the filter predicate of this
class. |
boolean |
containsKey(Object key)
Returns true if the base map contains a mapping for the specified key
and the key matches the underlying filter. |
Object |
get(Object key)
Returns the value to which the base map maps the specified key
if the key matches the underlying filter. |
protected Iterator |
getEntrySetIterator()
Returns the iterator of the entry set. |
Set |
keySet()
Returns a set view of the keys contained in this map. |
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in the base map
if the key matches the underlying filter. |
Object |
remove(Object key)
Removes the mapping for this key from this map if present
and the key matches the underlying filter. |
KeyFilteredMap
public KeyFilteredMap(Map base,
Predicate filter)
- Constructs a filtered map from the specified map and filter.
- Parameters:
base - the underlying mapfilter - predicate that determines which keys belong to the map- Throws:
NullPointerException - if the specified objects are
null.
getEntrySetIterator
protected Iterator getEntrySetIterator()
- Description copied from class:
AbstractMapWithSet
- Returns the iterator of the entry set.
- Overrides:
getEntrySetIterator in class AbstractMapWithSet
- Following copied from class:
net.sf.molae.pipe.basic.AbstractMapWithSet
- Returns:
- the iterator of the entry set.
assertRange
protected void assertRange(Object o)
- Checks if the specified object fulfils the filter predicate of this
class.
- Parameters:
o - parameter of another method of this class.- Throws:
IllegalArgumentException - if the specified object does not
fulfil the filter predicate of this class.
containsKey
public boolean containsKey(Object key)
- Returns true if the base map contains a mapping for the specified key
and the key matches the underlying filter.
- Overrides:
containsKey in class AbstractMap
- Throws:
ClassCastException - depending on the base mapNullPointerException - depending on the base map
get
public Object get(Object key)
- Returns the value to which the base map maps the specified key
if the key matches the underlying filter.
- Overrides:
get in class AbstractMap
- Throws:
ClassCastException - depending on the base mapNullPointerException - depending on the base map
put
public Object put(Object key,
Object value)
- Associates the specified value with the specified key in the base map
if the key matches the underlying filter.
- Overrides:
put in class AbstractMap
- Throws:
UnsupportedOperationException - depending on the base mapClassCastException - depending on the base mapIllegalArgumentException - depending on the base mapNullPointerException - depending on the base map
remove
public Object remove(Object key)
- Removes the mapping for this key from this map if present
and the key matches the underlying filter.
- Overrides:
remove in class AbstractMap
- Throws:
UnsupportedOperationException - depending on the base map
keySet
public Set keySet()
- Description copied from class:
AbstractMapWithSet
- Returns a set view of the keys contained in this map.
This implementation returns a
typesafe version of the key set
from AbstractMap
- Overrides:
keySet in class AbstractMapWithSet
- Following copied from class:
net.sf.molae.pipe.basic.AbstractMapWithSet
- Returns:
- a set view of the keys contained in this map.