Class FilterIterator<E>

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.util.Iterator<E>, CloseableIterator<E>

    public class FilterIterator<E>
    extends AbstractIterator<E>
    implements CloseableIterator<E>
    Iterator that also filters out entries based on the provided predicate. This iterator implements CloseableIterator and will close the provided iterator if it also implemented CloseableIterator.

    This iterator supports removal as long as the provided iterator supports removal. Although note only entries returned by the filter can be removed.

    • Constructor Summary

      Constructor Description
      FilterIterator​(java.util.Iterator<E> iter, java.util.function.Predicate<? super E> filter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      protected E getNext()
      Method to implement to provide an iterator implementation.
      void remove()  
      • 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, hasNext, next
    • Constructor Detail

      • FilterIterator

        public FilterIterator​(java.util.Iterator<E> iter,
                              java.util.function.Predicate<? super E> filter)
    • Method Detail

      • getNext

        protected E getNext()
        Description copied from class: AbstractIterator
        Method to implement to provide an iterator implementation. When this method returns null, the iterator is complete.
        Specified by:
        getNext in class AbstractIterator<E>
        the next value for the iterator to return or null for it to be complete.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface CloseableIterator<E>
      • remove

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