[Switch()...case]From String to enum
As may be I have made it more complex than what I wanted at the beginning my
code does not work with this :
public enum myMenuEnum {
/* we initialise menu item constants */
SOSA_SET("Set indexation with..."), SOSA_CHANGE(
"Change indexation to..."), SOSA_GET(
"Get individual from index..."), SOSA_REMOVE(
"Remove all indexes...");
private String item;
/* constructor for myMenuEnum */
myMenuEnum(String item) {
this.item = item;
}
/* method to retrieve menu string constant value */
public String getItem() {
return item;
}
}
When I want to test with a switch structure from a string value called
menuItem with this :
switch (myMenuEnum.valueOf(menuItem)) {
case SOSA_SET:
....
break;
case ...
break;
}
I get the following error message :
No enum const class genj.plugin.sosa.SosaMenuAction$myMenuEnum.Change
indexation to...
So apparently myMenuEnum.valueOf(menuItem) is not the proper variable to set
in switch () to test against SOSA_SET, SOSA_CHANGE, SOSA_GET or
SOSA_REMOVE.
What is wrong here.