I am writing a web application where in I need to have a lot of fixed values in the system to support operations and UI.I figured out it's better to put them in an Enum and group them using EnumSet as described in the Snippet below.
Now what I need is a way to retrieve only the values from a particular enum set based on the String input I provide.
For example: A method getFixedValues(identifier); where in identifer="VehicleType" should return CAR("10"), BIKE("20"),TRUCK("30")
I tried few things but not able to work my way out through EnumSet.
public enum MyEnum {
CAR("10"),
BIKE("20"),
TRUCK("30"),
XML("100"),
EDI("300"),
APP1("A1"),
APP2("A2");
String value;
private MyEnum() {
}
private MyEnum(String value) {
this.value = value;
}
public static EnumSet<MyEnum> VehicleType = EnumSet.of(CAR, BIKE, TRUCK);
public static EnumSet<MyEnum> MessageType = EnumSet.of(XML, EDI);
public static EnumSet<MyEnum> ApplicationType = EnumSet.of(APP1, APP2);}