Class ThreadSafeDelayedIteration<E>
- java.lang.Object
-
- org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E>
-
- org.eclipse.rdf4j.common.iteration.ThreadSafeDelayedIteration<E>
-
- All Implemented Interfaces:
AutoCloseable
,Iterator<E>
,CloseableIteration<E>
public abstract class ThreadSafeDelayedIteration<E> extends AbstractCloseableIteration<E>
An iteration that delays the creation of the underlying iteration until it is being accessed. This is mainly useful for situations where iteration creation adds considerable overhead but where the iteration may not actually be used, or where a created iteration consumes scarce resources like JDBC-connections or memory. Subclasses must implement the createIteration method, which is called once when the iteration is first needed.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ThreadSafeDelayedIteration()
Creates a new DelayedIteration.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract CloseableIteration<? extends E>
createIteration()
Creates the iteration that should be iterated over.protected void
handleClose()
Closes this iteration as well as the underlying iteration if it has already been created and happens to be aCloseableIteration
.boolean
hasNext()
Calls the hasNext method of the underlying iteration.E
next()
Calls the next method of the underlying iteration.void
remove()
Calls the remove method of the underlying iteration.-
Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosed
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.common.iteration.CloseableIteration
stream
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Method Detail
-
createIteration
protected abstract CloseableIteration<? extends E> createIteration()
Creates the iteration that should be iterated over. This method is called only once, when the iteration is first needed.
-
hasNext
public boolean hasNext()
Calls the hasNext method of the underlying iteration.
-
next
public E next()
Calls the next method of the underlying iteration.
-
remove
public void remove()
Calls the remove method of the underlying iteration.
-
handleClose
protected void handleClose()
Closes this iteration as well as the underlying iteration if it has already been created and happens to be aCloseableIteration
.- Specified by:
handleClose
in classAbstractCloseableIteration<E>
-
-