Class EnumerationIteratorAdapter<E>

  • Type Parameters:
    E - the type of elements returned by this iterator
    All Implemented Interfaces:
    java.util.Iterator<E>

    public class EnumerationIteratorAdapter<E>
    extends ReadOnlyIterator<E>
    An Iterator that adapts an Enumeration instance, providing a forward-only, read-only view of the elements.

    This class is particularly useful when working with legacy APIs that return an Enumeration, allowing them to be used in contexts expecting an Iterator.

    Example Usage

    
     Enumeration<String> enumeration = ...; // some legacy enumeration source
     Iterator<String> iterator = new EnumerationIteratorAdapter<>(enumeration);
    
     while (iterator.hasNext()) {
         String element = iterator.next();
         System.out.println(element);
     }
     

    Note: This implementation does not support the Iterator.remove() operation and will throw an IllegalStateException if called, as it inherits this behavior from ReadOnlyIterator.

    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    Enumeration, ReadOnlyIterator
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      E next()  
      • 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
    • Method Detail

      • hasNext

        public boolean hasNext()
      • next

        public E next()