Class FilteredIterator<E>

  • Type Parameters:
    E - The type of element returned by the iterator.
    All Implemented Interfaces:
    java.util.Iterator<E>

    public class FilteredIterator<E>
    extends AbstractFilteredIterator<E>
    An iterator that filters an existing iterator using a Filter.

    This version does not support AbstractPrimedIterator.remove().

    This version releases the decorated iterator when iteration is finished.

    This class is not thread safe.

    Author:
    Garret Wilson
    • Constructor Summary

      Constructors 
      Constructor Description
      FilteredIterator​(java.util.Iterator<E> iterator, Filter<E> filter)
      Decorated iterator and filter constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean isPass​(E element)
      Indicates whether the given element is included when filtering.
      • Methods inherited from class java.lang.Object

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

        forEachRemaining
    • Constructor Detail

      • FilteredIterator

        public FilteredIterator​(java.util.Iterator<E> iterator,
                                Filter<E> filter)
        Decorated iterator and filter constructor.
        Parameters:
        iterator - The decorated iterator to be filtered.
        filter - The filter for this iterator's elements.
        Throws:
        java.lang.NullPointerException - if the given iterator and/or filter is null.
    • Method Detail

      • isPass

        protected boolean isPass​(E element)
        Indicates whether the given element is included when filtering. This version delegates to Filter.isPass(Object).
        Specified by:
        isPass in class AbstractFilteredIterator<E>
        Parameters:
        element - The element in the filtered iterator.
        Returns:
        true if the element should be included, or null if it should be filtered out.