Package org.apache.commons.collections4.set

# 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 another `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());

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>`

- ## Field Summary

  ### Fields inherited from class org.apache.commons.collections4.collection.PredicatedCollection

  `predicate`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `PredicatedNavigableSet(NavigableSet<E> set, Predicate<? super E> predicate)`
  Constructor that wraps (not copies).

- ## Method Summary

  Modifier and Type
  Method
  Description
  `E`
  `ceiling(E e)`
  `protected NavigableSet<E>`
  `decorated()`
  Gets the navigable set being decorated.
  `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, validate`

  ### Methods inherited from class org.apache.commons.collections4.collection.AbstractCollectionDecorator

  `clear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeIf, retainAll, setCollection, size, toArray, toArray, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.util.Collection

  `parallelStream, removeIf, stream`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

  ### 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`

- ## Constructor Details

  - ### PredicatedNavigableSet

    protected PredicatedNavigableSet(NavigableSet<E> set, Predicate<? super E> predicate)
    Constructor that wraps (not copies).

    If there are any elements already in the set being decorated, they are validated.

    Parameters:
      `set` - The set to decorate, must not be null
      `predicate` - The predicate to use for validation, must not be null
    Throws:
      `NullPointerException` - if set or predicate is null
      `IllegalArgumentException` - if the set contains invalid elements

- ## Method Details

  - ### 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 null
      `predicate` - The predicate to use for validation, must not be null
    Returns:
      A new predicated navigable set.
    Throws:
      `NullPointerException` - if set or predicate is null
      `IllegalArgumentException` - if the set contains invalid elements
    Since:
      4.0

  - ### ceiling

    public E ceiling(E e)
    Specified by:
      `ceiling` in interface `NavigableSet<E>`

  - ### decorated

    protected NavigableSet<E> decorated()
    Gets the navigable set being decorated.
    Overrides:
      `decorated` in class `PredicatedSortedSet<E>`
    Returns:
      The decorated navigable set

  - ### descendingIterator

    public Iterator<E> descendingIterator()
    Specified by:
      `descendingIterator` in interface `NavigableSet<E>`

  - ### descendingSet

    public NavigableSet<E> descendingSet()
    Specified by:
      `descendingSet` in interface `NavigableSet<E>`

  - ### floor

    public E floor(E e)
    Specified by:
      `floor` in interface `NavigableSet<E>`

  - ### headSet

    public NavigableSet<E> headSet(E toElement, boolean inclusive)
    Specified by:
      `headSet` in interface `NavigableSet<E>`

  - ### higher

    public E higher(E e)
    Specified by:
      `higher` in interface `NavigableSet<E>`

  - ### lower

    public E lower(E e)
    Specified by:
      `lower` in interface `NavigableSet<E>`

  - ### pollFirst

    public E pollFirst()
    Specified by:
      `pollFirst` in interface `NavigableSet<E>`

  - ### pollLast

    public E pollLast()
    Specified by:
      `pollLast` in interface `NavigableSet<E>`

  - ### subSet

    public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
    Specified by:
      `subSet` in interface `NavigableSet<E>`

  - ### tailSet

    public NavigableSet<E> tailSet(E fromElement, boolean inclusive)
    Specified by:
      `tailSet` in interface `NavigableSet<E>`