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:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.NavigableSet<E>
,java.util.Set<E>
,java.util.SortedSet<E>
public class PredicatedNavigableSet<E> extends PredicatedSortedSet<E> implements java.util.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)
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)
-
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
-
-
-
-
Method Detail
-
predicatedNavigableSet
public static <E> PredicatedNavigableSet<E> predicatedNavigableSet(java.util.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:
java.lang.NullPointerException
- if set or predicate is nulljava.lang.IllegalArgumentException
- if the set contains invalid elements- Since:
- 4.0
-
descendingSet
public java.util.NavigableSet<E> descendingSet()
- Specified by:
descendingSet
in interfacejava.util.NavigableSet<E>
-
descendingIterator
public java.util.Iterator<E> descendingIterator()
- Specified by:
descendingIterator
in interfacejava.util.NavigableSet<E>
-
subSet
public java.util.NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
- Specified by:
subSet
in interfacejava.util.NavigableSet<E>
-
headSet
public java.util.NavigableSet<E> headSet(E toElement, boolean inclusive)
- Specified by:
headSet
in interfacejava.util.NavigableSet<E>
-
-