K
- the type of the keys in this mapV
- the type of the values in this mappublic class PredicatedSortedMap<K,V> extends PredicatedMap<K,V> implements java.util.SortedMap<K,V>
SortedMap
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.
SortedMap map = PredicatedSortedMap.predicatedSortedMap(new TreeMap(), NotNullPredicate.notNullPredicate(), null);
Note that PredicatedSortedMap 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 Collections.synchronizedSortedMap(java.util.SortedMap<K, V>)
. This class may throw
exceptions when accessed by concurrent threads without synchronization.
This class is Serializable from Commons Collections 3.1.
Modifier and Type | Method and Description |
---|---|
java.util.Comparator<? super K> |
comparator() |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
K |
firstKey() |
java.util.SortedMap<K,V> |
headMap(K toKey) |
K |
lastKey() |
static <K,V> PredicatedSortedMap<K,V> |
predicatedSortedMap(java.util.SortedMap<K,V> map,
Predicate<? super K> keyPredicate,
Predicate<? super V> valuePredicate)
Factory method to create a predicated (validating) sorted map.
|
java.util.SortedMap<K,V> |
subMap(K fromKey,
K toKey) |
java.util.SortedMap<K,V> |
tailMap(K fromKey) |
predicatedMap, put, putAll
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, remove, size, toString, values
mapIterator
public static <K,V> PredicatedSortedMap<K,V> predicatedSortedMap(java.util.SortedMap<K,V> map, Predicate<? super K> keyPredicate, Predicate<? super V> valuePredicate)
If there are any elements already in the list being decorated, they are validated.
K
- the key typeV
- the value typemap
- the map to decorate, must not be nullkeyPredicate
- the predicate to validate the keys, null means no checkvaluePredicate
- the predicate to validate to values, null means no checkjava.lang.NullPointerException
- if the map is nullpublic java.util.Comparator<? super K> comparator()
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in interface java.util.Map<K,V>
entrySet
in interface Get<K,V>
entrySet
in class AbstractMapDecorator<K,V>
Map.entrySet()
Copyright © 2010 - 2020 Adobe. All Rights Reserved