I have a problem in Java using Enums. I have read the documentation about assigning value parameters to Enums. But, my question is what about multiple values, is it possible
Wow, really quick reply :) Thanks guys.
Andy is right. I want to call Language.valueOf("eng") or Language.valueOf("english") and get Language.English as return.
I already have a utility function that does this, but it's not very nice. Switch function that checks string values and return appropriate enum instance.
But there is a lot of code rewriting (I have cca 30-40 languages). And if I want to add a language, I have to add it to enum, and implement a new check in the utility class.
I'll try Flavios approach. Just one question. Your constructor, shouldn't it be?
Language(List values) {
this.values = Arrays.asList(values);
}