Class CriterionIterator<T>

  • Type Parameters:
    T - type of objects to iterate
    All Implemented Interfaces:
    java.util.Iterator<T>

    public final class CriterionIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>

    An Iterator that filters the objects of an existing iterator using a Criterion.

    Iterator.remove() is not supported.

    Author:
    agz
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      T next()  
      void remove()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • CriterionIterator

        public CriterionIterator​(java.util.Iterator<? extends T> iterator,
                                 Criterion<? super T> criterion)
        Creates a new CriterionIterator, that filters the objects of the specified iterator using the specified Criterion.

        The specified iterator must not be null.

        The specified criterion may be null, in which case no filtering is done and the returned iterator iterates through all objects of the specified iterator.

        Parameters:
        iterator - underlying iterator whose iteration should be filtered
        criterion - filter-Criterion
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface java.util.Iterator<T>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<T>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object