Class PredicatedNavigableSet<E>

  • Type Parameters:
    E - the type of the elements in this set
    All Implemented Interfaces:, 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 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(),
    See Also:
    Serialized Form
    • 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
        set - the set to decorate, must not be null
        predicate - the predicate to use for validation, must not be null
        a new predicated navigable set.
        java.lang.NullPointerException - if set or predicate is null
        java.lang.IllegalArgumentException - if the set contains invalid elements
      • lower

        public E lower​(E e)
        Specified by:
        lower in interface java.util.NavigableSet<E>
      • floor

        public E floor​(E e)
        Specified by:
        floor in interface java.util.NavigableSet<E>
      • ceiling

        public E ceiling​(E e)
        Specified by:
        ceiling in interface java.util.NavigableSet<E>
      • higher

        public E higher​(E e)
        Specified by:
        higher in interface java.util.NavigableSet<E>
      • pollFirst

        public E pollFirst()
        Specified by:
        pollFirst in interface java.util.NavigableSet<E>
      • pollLast

        public E pollLast()
        Specified by:
        pollLast in interface java.util.NavigableSet<E>
      • descendingSet

        public java.util.NavigableSet<E> descendingSet()
        Specified by:
        descendingSet in interface java.util.NavigableSet<E>
      • descendingIterator

        public java.util.Iterator<E> descendingIterator()
        Specified by:
        descendingIterator in interface java.util.NavigableSet<E>
      • subSet

        public java.util.NavigableSet<E> subSet​(E fromElement,
                                                boolean fromInclusive,
                                                E toElement,
                                                boolean toInclusive)
        Specified by:
        subSet in interface java.util.NavigableSet<E>
      • headSet

        public java.util.NavigableSet<E> headSet​(E toElement,
                                                 boolean inclusive)
        Specified by:
        headSet in interface java.util.NavigableSet<E>
      • tailSet

        public java.util.NavigableSet<E> tailSet​(E fromElement,
                                                 boolean inclusive)
        Specified by:
        tailSet in interface java.util.NavigableSet<E>