public class PredicatedNavigableSet<E> extends PredicatedSortedSet<E> implements 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> predicate| Modifier | Constructor and Description |
|---|---|
protected |
PredicatedNavigableSet(NavigableSet
Constructor that wraps (not copies).
|
| Modifier and Type | Method and Description |
|---|---|
E |
ceiling(E e)
|
protected NavigableSet |
decorated()
Gets the navigable set being decorated.
|
Iterator |
descendingIterator()
|
NavigableSet |
descendingSet()
|
E |
floor(E e)
|
NavigableSet |
headSet(E toElement, boolean inclusive)
|
E |
higher(E e)
|
E |
lower(E e)
|
E |
pollFirst()
|
E |
pollLast()
|
static <E> PredicatedNavigableSet |
predicatedNavigableSet(NavigableSet
Factory method to create a predicated (validating) navigable set.
|
NavigableSet |
subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
|
NavigableSet |
tailSet(E fromElement, boolean inclusive)
|
comparator, first, headSet, last, predicatedSortedSet, subSet, tailSetequals, hashCode, predicatedSetadd, addAll, builder, notNullBuilder, predicatedCollection, validateclear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, setCollection, size, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitheadSet, iterator, subSet, tailSetcomparator, first, last, spliteratoradd, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArrayparallelStream, removeIf, streamprotected PredicatedNavigableSet(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 null
predicate - the predicate to use for validation, must not be null
NullPointerException - if set or predicate is null
IllegalArgumentException - if the set contains invalid elements
public static <E> PredicatedNavigableSet<E> predicatedNavigableSet(NavigableSet <E> set, Predicate <? super E> predicate)
If there are any elements already in the set being decorated, they are validated.
E - the element type
set - the set to decorate, must not be null
predicate - the predicate to use for validation, must not be null
NullPointerException - if set or predicate is null
IllegalArgumentException - if the set contains invalid elements
protected NavigableSet<E> decorated()
decorated in class
PredicatedSortedSet<E>
public E pollFirst()
public E pollLast()
public NavigableSet<E> descendingSet()
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
public NavigableSet<E> headSet(E toElement, boolean inclusive)
public NavigableSet<E> tailSet(E fromElement, boolean inclusive)