SortedSet 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.
SortedSet set =
PredicatedSortedSet.predicatedSortedSet(new TreeSet(),
NotNullPredicate.notNullPredicate());
This class is Serializable from Commons Collections 3.1.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| protected | PredicatedSortedSet(final SortedSet<E>
the set to decorate, must not be null set, final Predicate<? super E> the predicate to use for validation, must not be null predicate)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public Comparator | comparator()
Implements java. null if this set uses the natural ordering of its elements.
|
| protected SortedSet | Returns: the decorated sorted setOverrides org. |
| public E | first()
Implements java. |
| public SortedSet | headSet(final E
high endpoint (exclusive) of the returned set toElement)Implements java. toElement.
|
| public E | last()
Implements java. |
| public static < the element type E> PredicatedSortedSet | Returns: a new predicated sorted set.the set to decorate, must not be null set, final Predicate<? super E> the predicate to use for validation, must not be null predicate)Factory method to create a predicated (validating) sorted set. |
| public SortedSet | subSet(final E
low endpoint (inclusive) of the returned set fromElement, final E high endpoint (exclusive) of the returned set toElement)Implements java. fromElement, inclusive, to toElement,
exclusive.
|
| public SortedSet | tailSet(final E
low endpoint (inclusive) of the returned set fromElement)Implements java. fromElement.
|
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| PredicatedSortedSet | back to summary |
|---|---|
| protected PredicatedSortedSet(final SortedSet<E> set, final Predicate<? super E> predicate) Constructor that wraps (not copies). If there are any elements already in the set being decorated, they are validated.
| |
| comparator | back to summary |
|---|---|
| public Comparator Implements java. Doc from java. Returns the comparator used to order the elements in this set,
or
| |
| decorated | back to summary |
|---|---|
| protected SortedSet Overrides org. Gets the sorted set being decorated. | |
| first | back to summary |
|---|---|
| public E first() Implements java. Doc from java. Returns the first (lowest) element currently in this set.
| |
| headSet | back to summary |
|---|---|
| public SortedSet Implements java. Doc from java. Returns a view of the portion of this set whose elements are
strictly less than The returned set will throw an | |
| last | back to summary |
|---|---|
| public E last() Implements java. Doc from java. Returns the last (highest) element currently in this set.
| |
| predicatedSortedSet | back to summary |
|---|---|
| public static <E> PredicatedSortedSet Factory method to create a predicated (validating) sorted set. If there are any elements already in the set being decorated, they are validated.
| |
| subSet | back to summary |
|---|---|
| public SortedSet Implements java. Doc from java. Returns a view of the portion of this set whose elements range
from The returned set will throw an | |
| tailSet | back to summary |
|---|---|
| public SortedSet Implements java. Doc from java. Returns a view of the portion of this set whose elements are
greater than or equal to The returned set will throw an | |