Package org.apache.commons.lang.enums

Provides an implementation of the C style enum in the Java world.

See:
          Description

Class Summary
Enum Abstract superclass for type-safe enums.
EnumUtils Utility class for accessing and manipulating Enums.
ValuedEnum Abstract superclass for type-safe enums with integer values suitable for use in switch statements.
 

Package org.apache.commons.lang.enums Description

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


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.