Class RemovableIterator<C>

  • All Implemented Interfaces:
    java.util.Iterator<C>
    Direct Known Subclasses:
    RemovableCloseableIterator

    public class RemovableIterator<C>
    extends java.lang.Object
    implements java.util.Iterator<C>
    An Iterator implementation that allows for a Iterator that doesn't allow remove operations to implement remove by delegating the call to the provided consumer to remove the previously read value.
    Since:
    9.1
    Author:
    wburns
    • Constructor Summary

      Constructors 
      Constructor Description
      RemovableIterator​(java.util.Iterator<C> realIterator, java.util.function.Consumer<? super C> consumer)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected C getNextFromIterator()  
      boolean hasNext()  
      C next()  
      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
    • Field Detail

      • realIterator

        protected final java.util.Iterator<C> realIterator
      • consumer

        protected final java.util.function.Consumer<? super C> consumer
      • previousValue

        protected C previousValue
      • currentValue

        protected C currentValue
    • Constructor Detail

      • RemovableIterator

        public RemovableIterator​(java.util.Iterator<C> realIterator,
                                 java.util.function.Consumer<? super C> consumer)
    • Method Detail

      • getNextFromIterator

        protected C getNextFromIterator()
      • hasNext

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

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

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