Package io.microsphere.collection
Class EnumerationIteratorAdapter<E>
- java.lang.Object
-
- io.microsphere.collection.ReadOnlyIterator<E>
-
- io.microsphere.collection.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>
AnIterator
that adapts anEnumeration
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 anIterator
.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 anIllegalStateException
if called, as it inherits this behavior fromReadOnlyIterator
.- 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 io.microsphere.collection.ReadOnlyIterator
remove
-
-
-
-
Method Detail
-
hasNext
public boolean hasNext()
-
next
public E next()
-
-