In this code I get a compiler error, see comment:
public enum Type {
CHANGESET(\"changeset\"),
NEW_TICKET(\"newticket\"),
TICKET_CHANGED(\"editedti
The map is probably overkill here. Unless you are planning on having many more than four enum values you can implement getByTracName(String tn) by simply iterating over the valid strings and returning the correct one. If the map keys are always the enum names then you can do:
public enum Type {
CHANGESET,
NEW_TICKET,
TICKET_CHANGED,
CLOSED_TICKET;
private static final Map tracNameMap = new HashMap();
static {
for (Type t:Type.values()) {
tracNameMap.put(t.name(), t);
}
}
public static Type getByTracName(String tn) {
return tracNameMap.get(tracNameMap);
}
}
or you can do:
public static Type getByTracName(String tn) {
return Enum.valueOf(Type.class,tn);
}