Skip to content

io microsphere collection EnumerationUtils

github-actions[bot] edited this page Apr 11, 2026 · 5 revisions

EnumerationUtils

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

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

Overview

The utilities class for Java Enumeration

Declaration

public abstract class EnumerationUtils implements Utils

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.8-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

Method Examples

isEnumeration

boolean result = EnumerationUtils.isEnumeration(someObject);
if (result) {
    Enumeration<?> enumeration = (Enumeration<?>) someObject;
    while (enumeration.hasMoreElements()) {
        System.out.println(enumeration.nextElement());
    }
}

isEnumeration

boolean result = EnumerationUtils.isEnumeration(SomeEnumClass.class);
if (result) {
    // The class is an Enumeration
}

of

Enumeration<String> en = EnumerationUtils.of("one", "two", "three");
while (en.hasMoreElements()) {
    System.out.println(en.nextElement());
}

ofEnumeration

Enumeration<String> en = EnumerationUtils.ofEnumeration("apple", "banana", "cherry");
while (en.hasMoreElements()) {
    System.out.println(en.nextElement());
}

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.EnumerationUtils;

API Reference

Public Methods

Method Description
isEnumeration Checks if the given object is an instance of Enumeration.
isEnumeration Checks if the given class type is assignable from Enumeration.
of Creates an Enumeration from the provided elements.
ofEnumeration Creates an Enumeration from the provided elements array.

Method Details

isEnumeration

public static boolean isEnumeration(@Nullable Object values)

Checks if the given object is an instance of Enumeration.

Example Usage

`boolean result = EnumerationUtils.isEnumeration(someObject);
if (result) {
    Enumeration enumeration = (Enumeration) someObject;
    while (enumeration.hasMoreElements()) {
        System.out.println(enumeration.nextElement());
    `
}
}

isEnumeration

public static boolean isEnumeration(@Nullable Class<?> type)

Checks if the given class type is assignable from Enumeration.

Example Usage

`boolean result = EnumerationUtils.isEnumeration(SomeEnumClass.class);
if (result) {
    // The class is an Enumeration
`
}

of

public static <E> Enumeration<E> of(E... elements)

Creates an Enumeration from the provided elements.

Internally, this method delegates to #ofEnumeration(Object[]) to create a new enumeration based on the given array of elements.

Example Usage

`Enumeration en = EnumerationUtils.of("one", "two", "three");
while (en.hasMoreElements()) {
    System.out.println(en.nextElement());
`
}

ofEnumeration

public static <E> Enumeration<E> ofEnumeration(E... elements)

Creates an Enumeration from the provided elements array.

This method constructs a new ArrayEnumeration instance backed by the given array, allowing sequential read-only access to the array elements.

Example Usage

`Enumeration en = EnumerationUtils.ofEnumeration("apple", "banana", "cherry");
while (en.hasMoreElements()) {
    System.out.println(en.nextElement());
`
}

See Also

  • Enumeration
  • Collections#enumeration

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

Home

annotation-processor

java-annotations

java-core

java-test

jdk-tools

lang-model

Clone this wiki locally