John Doe :
I created Enum with additional quoted in string value. When i call this value from Enum in any class i got value, but without quotes.
My Enum:
public enum ValueMapping {
BSE_M("BSE_MEDIUM"),
REPS("\"REPS\""),
TBOMD("TBOMD");
private String name;
ValueMapping(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static ValueMapping getByName(String name) {
ValueMapping result = null;
for (ValueMapping operName : values()) {
if (operName.getName().equals(name)) {
result = operName;
break;
}
}
return result;
}
}
How i try to get value from Enum:
ValueMapping.REPS.name()
Question: Is any way to get value from Enum with quotation marks?
Naman :
You can use the getName()
as:
ValueMapping.REPS.getName()
for e.g.
System.out.println(ValueMapping.REPS.getName());
would print "REPS"