Class EnumUtils
Utility class for accessing and manipulating Enum
s.
- Since:
- 2.1 (class existed in enum package from v1.0)
- Version:
- $Id: EnumUtils.java 905636 2010-02-02 14:03:32Z niallp $
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ValuedEnum
Gets aValuedEnum
object by class and value.static Enum
Gets anEnum
object by class and name.static List
getEnumList
(Class enumClass) Gets theList
ofEnum
objects using theEnum
class.static Map
getEnumMap
(Class enumClass) Gets theMap
ofEnum
objects by name using theEnum
class.static Iterator
Gets anIterator
over theEnum
objects in anEnum
class.
-
Constructor Details
-
EnumUtils
public EnumUtils()Public constructor. This class should not normally be instantiated.- Since:
- 2.0
-
-
Method Details
-
getEnum
Gets an
Enum
object by class and name.- Parameters:
enumClass
- the class of theEnum
to getname
- the name of the Enum to get, may benull
- Returns:
- the enum object
- Throws:
IllegalArgumentException
- if the enum class isnull
-
getEnum
Gets a
ValuedEnum
object by class and value.- Parameters:
enumClass
- the class of theEnum
to getvalue
- the value of theEnum
to get- Returns:
- the enum object, or null if the enum does not exist
- Throws:
IllegalArgumentException
- if the enum class isnull
-
getEnumMap
Gets the
Map
ofEnum
objects by name using theEnum
class.If the requested class has no enum objects an empty
Map
is returned. TheMap
is unmodifiable.- Parameters:
enumClass
- the class of theEnum
to get- Returns:
- the enum object Map
- Throws:
IllegalArgumentException
- if the enum class isnull
IllegalArgumentException
- if the enum class is not a subclass ofEnum
-
getEnumList
Gets the
List
ofEnum
objects using theEnum
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. TheList
is unmodifiable.- Parameters:
enumClass
- the class of the Enum to get- Returns:
- the enum object Map
- Throws:
IllegalArgumentException
- if the enum class isnull
IllegalArgumentException
- if the enum class is not a subclass ofEnum
-
iterator
Gets an
Iterator
over theEnum
objects in anEnum
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. TheIterator
is unmodifiable.- Parameters:
enumClass
- the class of theEnum
to get- Returns:
- an
Iterator
of theEnum
objects - Throws:
IllegalArgumentException
- if the enum class isnull
IllegalArgumentException
- if the enum class is not a subclass ofEnum
-