To generate a instance of a enum class by a given string you can use the valueOf() method.
1 2 3 4 5 6 7 8 9 10 11 | public class EnumByGivenStringSample { private enum Language { JAVA, RUBY, SCALA, GROOVY, CLOJURE } public static Language languageByString(String language) { return Language.valueOf(language); } } |
Information about Data protection