Class AbstractIterator<E>

  • All Implemented Interfaces:
    java.util.Iterator<E>
    Direct Known Subclasses:
    ConcatIterator, FilterIterator

    public abstract class AbstractIterator<E>
    extends java.lang.Object
    implements java.util.Iterator<E>
    Abstract iterator that allows overriding just the getNext() method to implement it. This iterator works on the premise that a null value returned from getNext() means that this iterator is complete. Note this iterator does not implement Iterator.remove() and is up to implementors to do so.
    Since:
    9.2
    Author:
    wburns
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void forEachRemaining​(java.util.function.Consumer<? super E> action)  
      protected abstract E getNext()
      Method to implement to provide an iterator implementation.
      boolean hasNext()  
      E next()  
      • 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

        remove
    • Constructor Detail

      • AbstractIterator

        public AbstractIterator()
    • Method Detail

      • getNext

        protected abstract E getNext()
        Method to implement to provide an iterator implementation. When this method returns null, the iterator is complete.
        Returns:
        the next value for the iterator to return or null for it to be complete.
      • hasNext

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

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

        public void forEachRemaining​(java.util.function.Consumer<? super E> action)
        Specified by:
        forEachRemaining in interface java.util.Iterator<E>