Class IteratorEnumeration<E>
java.lang.Object
org.apache.commons.collections4.iterators.IteratorEnumeration<E>
- Type Parameters:
E
- the type of elements returned by this iterator.
- All Implemented Interfaces:
Enumeration<E>
Adapter to make an
Iterator
instance appear to be an
Enumeration
instance.- Since:
- 1.0
-
Constructor Summary
ConstructorDescriptionConstructs a newIteratorEnumeration
that will not function untilsetIterator
is invoked.IteratorEnumeration
(Iterator<? extends E> iterator) Constructs a newIteratorEnumeration
that will use the given iterator. -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlying iterator.boolean
Returns true if the underlying iterator has more elements.Returns the next element from the underlying iterator.void
setIterator
(Iterator<? extends E> iterator) Sets the underlying iterator.
-
Constructor Details
-
IteratorEnumeration
public IteratorEnumeration()Constructs a newIteratorEnumeration
that will not function untilsetIterator
is invoked. -
IteratorEnumeration
Constructs a newIteratorEnumeration
that will use the given iterator.- Parameters:
iterator
- the iterator to use
-
-
Method Details
-
getIterator
Returns the underlying iterator.- Returns:
- the underlying iterator
-
hasMoreElements
Returns true if the underlying iterator has more elements.- Specified by:
hasMoreElements
in interfaceEnumeration<E>
- Returns:
- true if the underlying iterator has more elements
-
nextElement
Returns the next element from the underlying iterator.- Specified by:
nextElement
in interfaceEnumeration<E>
- Returns:
- the next element from the underlying iterator.
- Throws:
NoSuchElementException
- if the underlying iterator has no more elements
-
setIterator
Sets the underlying iterator.- Parameters:
iterator
- the new underlying iterator
-