Class IteratorEnumeration<E>
- java.lang.Object
-
- org.apache.commons.collections4.iterators.IteratorEnumeration<E>
-
- All Implemented Interfaces:
Enumeration<E>
public class IteratorEnumeration<E> extends Object implements Enumeration<E>
Adapter to make anIteratorinstance appear to be anEnumerationinstance.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description IteratorEnumeration()Constructs a newIteratorEnumerationthat will not function untilsetIteratoris invoked.IteratorEnumeration(Iterator<? extends E> iterator)Constructs a newIteratorEnumerationthat will use the given iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<? extends E>getIterator()Returns the underlying iterator.booleanhasMoreElements()Returns true if the underlying iterator has more elements.EnextElement()Returns the next element from the underlying iterator.voidsetIterator(Iterator<? extends E> iterator)Sets the underlying iterator.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Enumeration
asIterator
-
-
-
-
Constructor Detail
-
IteratorEnumeration
public IteratorEnumeration()
Constructs a newIteratorEnumerationthat will not function untilsetIteratoris invoked.
-
-
Method Detail
-
hasMoreElements
public boolean hasMoreElements()
Returns true if the underlying iterator has more elements.- Specified by:
hasMoreElementsin interfaceEnumeration<E>- Returns:
- true if the underlying iterator has more elements
-
nextElement
public E nextElement()
Returns the next element from the underlying iterator.- Specified by:
nextElementin interfaceEnumeration<E>- Returns:
- the next element from the underlying iterator.
- Throws:
NoSuchElementException- if the underlying iterator has no more elements
-
getIterator
public Iterator<? extends E> getIterator()
Returns the underlying iterator.- Returns:
- the underlying iterator
-
-