Class AbstractIterator<T>
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.collections.AbstractIterator<T>
-
- Type Parameters:
T- the type of elements returned by this iterator
- All Implemented Interfaces:
Iterator<T>
- Direct Known Subclasses:
BlobReferenceIterator,DepthFirstNodeIterator,JournalReader
public abstract class AbstractIterator<T> extends Object implements Iterator<T>
An abstract base class for implementing iterators with custom logic. Subclasses should implementcomputeNext()to provide elements and must callendOfData()to signal no more element.The iteration ends when
endOfData()is called fromcomputeNext().
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractIterator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TcomputeNext()Computes the next element in the iteration.protected TendOfData()Signals that the iteration has no more elements.booleanhasNext()Tnext()-
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, remove
-
-
-
-
Method Detail
-
computeNext
protected abstract T computeNext()
Computes the next element in the iteration. Subclasses must implement this method and callendOfData()when no more elements are available.- Returns:
- the next element, or
endOfData()if iteration is over
-
endOfData
protected final T endOfData()
Signals that the iteration has no more elements. Should be called fromcomputeNext()to end iteration.- Returns:
- null, indicating end of data
-
-