Class PredicatedNavigableSet<E>
- java.lang.Object
-
- org.apache.commons.collections4.collection.AbstractCollectionDecorator<E>
-
- org.apache.commons.collections4.collection.PredicatedCollection<E>
-
- org.apache.commons.collections4.set.PredicatedSet<E>
-
- org.apache.commons.collections4.set.PredicatedSortedSet<E>
-
- org.apache.commons.collections4.set.PredicatedNavigableSet<E>
-
- Type Parameters:
E
- the type of the elements in this set
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,NavigableSet<E>
,Set<E>
,SortedSet<E>
public class PredicatedNavigableSet<E> extends PredicatedSortedSet<E> implements NavigableSet<E>
Decorates anotherNavigableSet
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());
- Since:
- 4.1
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.collections4.collection.PredicatedCollection
PredicatedCollection.Builder<E>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description E
ceiling(E e)
Iterator<E>
descendingIterator()
NavigableSet<E>
descendingSet()
E
floor(E e)
NavigableSet<E>
headSet(E toElement, boolean inclusive)
E
higher(E e)
E
lower(E e)
E
pollFirst()
E
pollLast()
static <E> PredicatedNavigableSet<E>
predicatedNavigableSet(NavigableSet<E> set, Predicate<? super E> predicate)
Factory method to create a predicated (validating) navigable set.NavigableSet<E>
subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
NavigableSet<E>
tailSet(E fromElement, boolean inclusive)
-
Methods inherited from class org.apache.commons.collections4.set.PredicatedSortedSet
comparator, first, headSet, last, predicatedSortedSet, subSet, tailSet
-
Methods inherited from class org.apache.commons.collections4.set.PredicatedSet
equals, hashCode, predicatedSet
-
Methods inherited from class org.apache.commons.collections4.collection.PredicatedCollection
add, addAll, builder, notNullBuilder, predicatedCollection
-
Methods inherited from class org.apache.commons.collections4.collection.AbstractCollectionDecorator
clear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, toArray, toArray, toString
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.NavigableSet
headSet, iterator, subSet, tailSet
-
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
-
Methods inherited from interface java.util.SortedSet
comparator, first, last, spliterator
-
-
-
-
Method Detail
-
predicatedNavigableSet
public static <E> PredicatedNavigableSet<E> predicatedNavigableSet(NavigableSet<E> set, Predicate<? super E> predicate)
Factory method to create a predicated (validating) navigable set.If there are any elements already in the set being decorated, they are validated.
- Type Parameters:
E
- the element type- Parameters:
set
- the set to decorate, must not be nullpredicate
- the predicate to use for validation, must not be null- Returns:
- a new predicated navigable set.
- Throws:
NullPointerException
- if set or predicate is nullIllegalArgumentException
- if the set contains invalid elements- Since:
- 4.0
-
lower
public E lower(E e)
- Specified by:
lower
in interfaceNavigableSet<E>
-
floor
public E floor(E e)
- Specified by:
floor
in interfaceNavigableSet<E>
-
ceiling
public E ceiling(E e)
- Specified by:
ceiling
in interfaceNavigableSet<E>
-
higher
public E higher(E e)
- Specified by:
higher
in interfaceNavigableSet<E>
-
pollFirst
public E pollFirst()
- Specified by:
pollFirst
in interfaceNavigableSet<E>
-
pollLast
public E pollLast()
- Specified by:
pollLast
in interfaceNavigableSet<E>
-
descendingSet
public NavigableSet<E> descendingSet()
- Specified by:
descendingSet
in interfaceNavigableSet<E>
-
descendingIterator
public Iterator<E> descendingIterator()
- Specified by:
descendingIterator
in interfaceNavigableSet<E>
-
subSet
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
- Specified by:
subSet
in interfaceNavigableSet<E>
-
headSet
public NavigableSet<E> headSet(E toElement, boolean inclusive)
- Specified by:
headSet
in interfaceNavigableSet<E>
-
tailSet
public NavigableSet<E> tailSet(E fromElement, boolean inclusive)
- Specified by:
tailSet
in interfaceNavigableSet<E>
-
-