Class AbstractIteratorDecorator<E>
- java.lang.Object
-
- com.globalmentor.collections.iterators.AbstractIteratorDecorator<E>
-
- Type Parameters:
E
- the type of elements returned by this iterator.
- All Implemented Interfaces:
java.util.Enumeration<E>
,java.util.Iterator<E>
- Direct Known Subclasses:
IteratorDecorator
,JoinIterator
public abstract class AbstractIteratorDecorator<E> extends java.lang.Object implements java.util.Iterator<E>, java.util.Enumeration<E>
An abstract base implementation of an iterator that wraps an existingIterator
.- Author:
- Garret Wilson
- API Note:
- This iterator also serves as an adapter, converting an iterator to an
Enumeration
. - Implementation Note:
- Subclasses may override
hasNext()
and/ornext()
, andEnumeration
compatibility will be maintained., This implementation specifically does not overrideIterator.forEachRemaining(Consumer)
to delegate to the underlying iterator's version of the method, because subclasses are allowed to change the decorated iterator during iteration. Therefore the default method version is retained, which callshasNext()
andnext()
repeatedly, allowing a subclass to acquire a different underlying iterator if it desires.
-
-
Constructor Summary
Constructors Constructor Description AbstractIteratorDecorator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.util.Iterator<E>
getIterator()
boolean
hasMoreElements()
boolean
hasNext()
E
next()
E
nextElement()
void
remove()
-
-
-
Method Detail
-
getIterator
protected abstract java.util.Iterator<E> getIterator()
- Returns:
- The iterator this class decorates.
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<E>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<E>
-
hasMoreElements
public final boolean hasMoreElements()
-
-