Skip to content

io microsphere collection EnumerationIteratorAdapter

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

EnumerationIteratorAdapter

Type: Class | Module: microsphere-java-core | Package: io.microsphere.collection | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/collection/EnumerationIteratorAdapter.java

Overview

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 enumeration = ...; // some legacy enumeration source
Iterator 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.

Declaration

public class EnumerationIteratorAdapter<E> extends ReadOnlyIterator<E>

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Enumeration<String> enumeration = ...; // some legacy enumeration source
Iterator<String> iterator = new EnumerationIteratorAdapter<>(enumeration);

while (iterator.hasNext()) {
    String element = iterator.next();
    System.out.println(element);
}

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.collection.EnumerationIteratorAdapter;

API Reference

Public Methods

Method Description
hasNext
next

See Also

  • Enumeration
  • ReadOnlyIterator

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally