Package io.microsphere.collection
Class EnumerationUtils
- java.lang.Object
-
- io.microsphere.collection.EnumerationUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisEnumeration(java.lang.Class<?> type)Checks if the given class type is assignable fromEnumeration.static booleanisEnumeration(java.lang.Object values)Checks if the given object is an instance ofEnumeration.static <E> java.util.Enumeration<E>of(E... elements)Creates anEnumerationfrom the provided elements.static <E> java.util.Enumeration<E>ofEnumeration(E... elements)Creates anEnumerationfrom the provided elements array.
-
-
-
Method Detail
-
isEnumeration
public static boolean isEnumeration(@Nullable java.lang.Object values)
Checks if the given object is an instance ofEnumeration.Example Usage
boolean result = EnumerationUtils.isEnumeration(someObject); if (result) { Enumeration<?> enumeration = (Enumeration<?>) someObject; while (enumeration.hasMoreElements()) { System.out.println(enumeration.nextElement()); } }- Parameters:
values- the object to check- Returns:
trueif the object is an instance ofEnumeration,falseotherwise
-
isEnumeration
public static boolean isEnumeration(@Nullable java.lang.Class<?> type)
Checks if the given class type is assignable fromEnumeration.Example Usage
boolean result = EnumerationUtils.isEnumeration(SomeEnumClass.class); if (result) { // The class is an Enumeration }- Parameters:
type- the class type to check- Returns:
trueif the class is assignable fromEnumeration,falseotherwise
-
of
@Nonnull public static <E> java.util.Enumeration<E> of(E... elements)
Creates anEnumerationfrom 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<String> en = EnumerationUtils.of("one", "two", "three"); while (en.hasMoreElements()) { System.out.println(en.nextElement()); }- Type Parameters:
E- the type of the elements- Parameters:
elements- the array of elements to include in the enumeration- Returns:
- a non-null
Enumerationinstance containing the specified elements
-
ofEnumeration
@Nonnull public static <E> java.util.Enumeration<E> ofEnumeration(E... elements)
Creates anEnumerationfrom the provided elements array.This method constructs a new
ArrayEnumerationinstance backed by the given array, allowing sequential read-only access to the array elements.Example Usage
Enumeration<String> en = EnumerationUtils.ofEnumeration("apple", "banana", "cherry"); while (en.hasMoreElements()) { System.out.println(en.nextElement()); }- Type Parameters:
E- the type of the elements- Parameters:
elements- the array of elements to include in the enumeration- Returns:
- a non-null
Enumerationinstance containing the specified elements
-
-