org.apache.commons.lang.enums
public class EnumUtils extends Object
Utility class for accessing and manipulating Enums.
Since: 2.1 (class existed in enum package from v1.0)
Version: $Id: EnumUtils.java 437554 2006-08-28 06:21:41Z bayard $
See Also: Enum ValuedEnum
| Constructor Summary | |
|---|---|
| EnumUtils()
Public constructor. | |
| Method Summary | |
|---|---|
| static Enum | getEnum(Class enumClass, String name) Gets an |
| static ValuedEnum | getEnum(Class enumClass, int value) Gets a |
| static List | getEnumList(Class enumClass) Gets the The list is in the order that the objects were created (source code order). If the requested class has no enum objects an empty
|
| static Map | getEnumMap(Class enumClass) Gets the If the requested class has no enum objects an empty
|
| static Iterator | iterator(Class enumClass) Gets an The iterator is in the order that the objects were created (source code order). If the requested class has no enum objects an empty
|
Since: 2.0
Gets an Enum object by class and name.
Parameters: enumClass the class of the Enum to get name the name of the Enum to get, may be null
Returns: the enum object
Throws: IllegalArgumentException if the enum class is null
Gets a ValuedEnum object by class and value.
Parameters: enumClass the class of the Enum to get value the value of the Enum to get
Returns: the enum object, or null if the enum does not exist
Throws: IllegalArgumentException if the enum class is null
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.
Parameters: enumClass the class of the Enum to get
Returns: the enum object Map
Throws: IllegalArgumentException if the enum class is null IllegalArgumentException if the enum class is not a subclass
of Enum
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.
Parameters: enumClass the class of the Enum to get
Returns: the enum object Map
Throws: IllegalArgumentException if the enum class is null IllegalArgumentException if the enum class is not a subclass
of Enum
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.
Parameters: enumClass the class of the Enum to get
Returns: an Iterator of the Enum objects
Throws: IllegalArgumentException if the enum class is null IllegalArgumentException if the enum class is not a subclass of Enum