Im working on java, I have created an enum as follows:
public enum myEnum
{
india,
russian,
england,
north America
}
Above
just make your own valueOf like function in your enum class. Replace spaces with underscores. name your enum constants like this "north_america("North America")". If the method fails to find your enum it just returns the parameter.
public static String valueOfOrDefault(String myValue) {
//replace space with underscore so it matches enum name
String value=myValue.toUpperCase().replaceAll("\\s", "_");
for(myEnum type : myEnum.class.getEnumConstants()) {
if(type.name().equalsIgnoreCase(value)) {
return type.toString();
}
}
return myValue;
}