Class ForwardingIteratorWithForcedRemoval<T>

java.lang.Object
org.aksw.jena_sparql_api.rdf.collections.ForwardingIteratorWithForcedRemoval<T>
Type Parameters:
T -
All Implemented Interfaces:
Iterator<T>, org.apache.jena.atlas.iterator.IteratorCloseable<T>, org.apache.jena.atlas.lib.Closeable, org.apache.jena.util.iterator.ClosableIterator<T>

public class ForwardingIteratorWithForcedRemoval<T> extends Object implements org.apache.jena.util.iterator.ClosableIterator<T>
Iterator that forwards calls to another iterator. If it turns out that .remove() is not supported, the remaining items in the iterator will be preloaded at once. Removal will then pass the current item to a lambda that can remove the item from the underlying collection directly, such as by invoking collection.remove(item).
Author:
raven
  • Field Details

    • originalDelegate

      protected Iterator<T> originalDelegate
    • effectiveDelegate

      protected Iterator<T> effectiveDelegate
    • forceRemover

      protected Consumer<T> forceRemover
    • delegateRemoval

      protected boolean delegateRemoval
    • isNextCalled

      protected boolean isNextCalled
    • currentItem

      protected T currentItem
  • Constructor Details

    • ForwardingIteratorWithForcedRemoval

      public ForwardingIteratorWithForcedRemoval(Iterator<T> delegate, Consumer<T> forceRemover)
    • ForwardingIteratorWithForcedRemoval

      public ForwardingIteratorWithForcedRemoval(Iterator<T> delegate, Consumer<T> forceRemover, boolean delegateRemoval)
  • Method Details

    • hasNext

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

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

      public void remove()
      Specified by:
      remove in interface Iterator<T>
    • close

      public void close()
      Specified by:
      close in interface org.apache.jena.util.iterator.ClosableIterator<T>
      Specified by:
      close in interface org.apache.jena.atlas.lib.Closeable