I need to define an Enum type in Java. However, the values in the enum depends on a parameter.
public class EnumTest {
private Language lang;
public enum Language {English, Spanish, Chinese, German, Japanese;}
public enum Entity {
// ???
entityA("student"),
entityB("faculty"),
entityC("staff");
private String name;
Entity(String name) {
this.name = name;
}
}
public EnumTest(Language lang) {
this.lang = lang;
}
public static void main(String[] args) {
EnumTest testA = new EnumTest(Langauge.English);
EnumTest testB = new EnumTest(Language.Spanish);
}
}
For example, the instantiation of entityA, entityB, entityC will not be "student", "faculty", and "staff", if the parameter is not Langauge.English. It will be the corresponding words translated from English in other languages. So, the definition of the enum Entity depends on the parameter Lang.
How can I achieve?