Package org.apache.commons.collections4.iterators

# 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>`

public class IteratorEnumeration<E> extends Object implements Enumeration<E>
Adapter to make an `Iterator` instance appear to be an `Enumeration` instance.

Since:
  1.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `IteratorEnumeration()`
  Constructs a new `IteratorEnumeration` that will not function until `setIterator` is invoked.
  `IteratorEnumeration(Iterator<? extends E> iterator)`
  Constructs a new `IteratorEnumeration` that will use the given iterator.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Iterator<? extends E>`
  `getIterator()`
  Gets the underlying iterator.
  `boolean`
  `hasMoreElements()`
  Returns true if the underlying iterator has more elements.
  `E`
  `nextElement()`
  Returns the next element from the underlying iterator.
  `void`
  `setIterator(Iterator<? extends E> iterator)`
  Sets the underlying iterator.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### IteratorEnumeration

    public IteratorEnumeration()
    Constructs a new `IteratorEnumeration` that will not function until `setIterator` is invoked.

  - ### IteratorEnumeration

    public IteratorEnumeration(Iterator<? extends E> iterator)
    Constructs a new `IteratorEnumeration` that will use the given iterator.
    Parameters:
      `iterator` - The iterator to use

- ## Method Details

  - ### getIterator

    public Iterator<? extends E> getIterator()
    Gets the underlying iterator.
    Returns:
      The underlying iterator

  - ### hasMoreElements

    public boolean hasMoreElements()
    Returns true if the underlying iterator has more elements.
    Specified by:
      `hasMoreElements` in interface `Enumeration<E>`
    Returns:
      true if the underlying iterator has more elements

  - ### nextElement

    public E nextElement()
    Returns the next element from the underlying iterator.
    Specified by:
      `nextElement` in interface `Enumeration<E>`
    Returns:
      The next element from the underlying iterator.
    Throws:
      `NoSuchElementException` - if the underlying iterator has no more elements

  - ### setIterator

    public void setIterator(Iterator<? extends E> iterator)
    Sets the underlying iterator.
    Parameters:
      `iterator` - The new underlying iterator