public class EnumUtils
extends java.lang.Object
Utility class for accessing and manipulating Enum
s.
Enum
,
ValuedEnum
Constructor and Description |
---|
EnumUtils()
Public constructor.
|
Modifier and Type | Method and Description |
---|---|
static ValuedEnum |
getEnum(java.lang.Class enumClass,
int value)
Gets a
ValuedEnum object by class and value. |
static Enum |
getEnum(java.lang.Class enumClass,
java.lang.String name)
Gets an
Enum object by class and name. |
static java.util.List |
getEnumList(java.lang.Class enumClass)
Gets the
List of Enum objects using
the Enum class. |
static java.util.Map |
getEnumMap(java.lang.Class enumClass)
Gets the
Map of Enum objects by
name using the Enum class. |
static java.util.Iterator |
iterator(java.lang.Class enumClass)
Gets an
Iterator over the Enum objects
in an Enum class. |
public EnumUtils()
public static Enum getEnum(java.lang.Class enumClass, java.lang.String name)
Gets an Enum
object by class and name.
enumClass
- the class of the Enum
to getname
- the name of the Enum to get, may be null
java.lang.IllegalArgumentException
- if the enum class is null
public static ValuedEnum getEnum(java.lang.Class enumClass, int value)
Gets a ValuedEnum
object by class and value.
enumClass
- the class of the Enum
to getvalue
- the value of the Enum
to getjava.lang.IllegalArgumentException
- if the enum class is null
public static java.util.Map getEnumMap(java.lang.Class enumClass)
Gets the Map
of Enum
objects by
name using the Enum
class.
If the requested class has no enum objects an empty
Map
is returned. The Map
is unmodifiable.
enumClass
- the class of the Enum
to getjava.lang.IllegalArgumentException
- if the enum class is null
java.lang.IllegalArgumentException
- if the enum class is not a subclass
of Enum
public static java.util.List getEnumList(java.lang.Class enumClass)
Gets the List
of Enum
objects using
the Enum
class.
The list is in the order that the objects were created (source code order).
If the requested class has no enum objects an empty
List
is returned. The List
is unmodifiable.
enumClass
- the class of the Enum to getjava.lang.IllegalArgumentException
- if the enum class is null
java.lang.IllegalArgumentException
- if the enum class is not a subclass
of Enum
public static java.util.Iterator iterator(java.lang.Class enumClass)
Gets an Iterator
over the Enum
objects
in an Enum
class.
The iterator is in the order that the objects were created (source code order).
If the requested class has no enum objects an empty
Iterator
is returned. The Iterator
is unmodifiable.
enumClass
- the class of the Enum
to getIterator
of the Enum
objectsjava.lang.IllegalArgumentException
- if the enum class is null
java.lang.IllegalArgumentException
- if the enum class is not a subclass of Enum
Copyright © 2010 - 2020 Adobe. All Rights Reserved