org.apache.commons.lang.enums |
Provides an implementation of the C style enum in the Java world.
The classic example being an RGB color enumeration.
public final class ColorEnum extends Enum {
public static final ColorEnum RED = new ColorEnum("Red");
public static final ColorEnum GREEN = new ColorEnum("Green");
public static final ColorEnum BLUE = new ColorEnum("Blue");
private ColorEnum(String color) {
super(color);
}
public static ColorEnum getEnum(String color) {
return (ColorEnum) getEnum(ColorEnum.class, color);
}
public static Map getEnumMap() {
return getEnumMap(ColorEnum.class);
}
public static List getEnumList() {
return getEnumList(ColorEnum.class);
}
public static Iterator iterator() {
return iterator(ColorEnum.class);
}
}
@since 2.1
|
Java Source File Name | Type | Comment |
Broken1Enum.java | Class | Broken color enumeration. |
Broken1OperationEnum.java | Class | Broken Operator enumeration, null class. |
Broken2Enum.java | Class | Broken color enumeration. |
Broken2OperationEnum.java | Class | Broken Operator enumeration, getEnumClass() not superclass. |
Broken3Enum.java | Class | Broken color enumeration. |
Broken3OperationEnum.java | Class | Broken Operator enumeration, getEnumClass() is Enum.class. |
Broken4OperationEnum.java | Class | Broken Operator enumeration, getEnumClass() is ValuedEnum.class. |
Broken5OperationEnum.java | Class | Broken Operator enumeration, getEnumClass() is not an Enum class. |
ColorEnum.java | Class | Color enumeration. |
DummyEnum.java | Class | Dummy enumeration - no values. |
Enum.java | Class | Abstract superclass for type-safe enums.
One feature of the C programming language lacking in Java is enumerations. |
EnumEqualsTest.java | Class | Test cases for the
Enum class equals method. |
EnumTest.java | Class | Test cases for the
Enum class.
author: Stephen Colebourne author: Gary D. |
EnumTestSuite.java | Class | Test suite for the Enum package. |
EnumUtils.java | Class | |
EnumUtilsTest.java | Class | Test cases for the
Enum class. |
Extended1Enum.java | Class | Base extended enumeration. |
Extended2Enum.java | Class | Extended enumeration. |
Extended3Enum.java | Class | Extended enumeration. |
Nest.java | Class | Color enumeration demonstrating a normal simple nesting case. |
NestBroken.java | Class | Color enumeration which demonstrates how to break the enum system.
The class loader sees the two classes here as independent - the enum
class is nested, not an inner class. |
NestLinked.java | Class | Color enumeration which demonstrates how to define the constants in a
different class to the Enum. |
NestReferenced.java | Class | Color enumeration which demonstrates how to provide a view of the constants
in a different class to the Enum. |
OperationEnum.java | Class | Operator enumeration. |
ValuedColorEnum.java | Class | Color enumeration. |
ValuedEnum.java | Class | Abstract superclass for type-safe enums with integer values suitable
for use in switch statements.
NOTE:Due to the way in which Java ClassLoaders work, comparing
Enum objects should always be done using the equals() method,
not == . |
ValuedEnumTest.java | Class | Test cases for the
Enum class. |
ValuedLanguageEnum.java | Class | Language enumeration. |