public class PredicatedNavigableSet<E> extends PredicatedSortedSet<E> implements java.util.NavigableSet<E>
NavigableSet
to validate that all additions
match a specified predicate.
This set exists to provide validation for the decorated set. It is normally created to decorate an empty set. If an object cannot be added to the set, an IllegalArgumentException is thrown.
One usage would be to ensure that no null entries are added to the set.
NavigableSet set = PredicatedSortedSet.predicatedNavigableSet(new TreeSet(), NotNullPredicate.notNullPredicate());
PredicatedCollection.Builder<E>
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID
Serialization version
|
predicate
Modifier | Constructor and Description |
---|---|
protected |
PredicatedNavigableSet(java.util.NavigableSet<E> set,
Predicate<? super E> predicate)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
E |
ceiling(E e) |
protected java.util.NavigableSet<E> |
decorated()
Gets the navigable set being decorated.
|
java.util.Iterator<E> |
descendingIterator() |
java.util.NavigableSet<E> |
descendingSet() |
E |
floor(E e) |
java.util.NavigableSet<E> |
headSet(E toElement,
boolean inclusive) |
E |
higher(E e) |
E |
lower(E e) |
E |
pollFirst() |
E |
pollLast() |
static <E> PredicatedNavigableSet<E> |
predicatedNavigableSet(java.util.NavigableSet<E> set,
Predicate<? super E> predicate)
Factory method to create a predicated (validating) navigable set.
|
java.util.NavigableSet<E> |
subSet(E fromElement,
boolean fromInclusive,
E toElement,
boolean toInclusive) |
java.util.NavigableSet<E> |
tailSet(E fromElement,
boolean inclusive) |
comparator, first, headSet, last, predicatedSortedSet, subSet, tailSet
equals, hashCode, predicatedSet
add, addAll, builder, notNullBuilder, predicatedCollection, validate
clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, setCollection, size, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
private static final long serialVersionUID
protected PredicatedNavigableSet(java.util.NavigableSet<E> set, Predicate<? super E> predicate)
If there are any elements already in the set being decorated, they are validated.
set
- the set to decorate, must not be nullpredicate
- the predicate to use for validation, must not be nulljava.lang.NullPointerException
- if set or predicate is nulljava.lang.IllegalArgumentException
- if the set contains invalid elementspublic static <E> PredicatedNavigableSet<E> predicatedNavigableSet(java.util.NavigableSet<E> set, Predicate<? super E> predicate)
If there are any elements already in the set being decorated, they are validated.
E
- the element typeset
- the set to decorate, must not be nullpredicate
- the predicate to use for validation, must not be nulljava.lang.NullPointerException
- if set or predicate is nulljava.lang.IllegalArgumentException
- if the set contains invalid elementsprotected java.util.NavigableSet<E> decorated()
decorated
in class PredicatedSortedSet<E>
public java.util.NavigableSet<E> descendingSet()
descendingSet
in interface java.util.NavigableSet<E>
public java.util.Iterator<E> descendingIterator()
descendingIterator
in interface java.util.NavigableSet<E>
public java.util.NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
subSet
in interface java.util.NavigableSet<E>
public java.util.NavigableSet<E> headSet(E toElement, boolean inclusive)
headSet
in interface java.util.NavigableSet<E>