Is it possible to load from file .properties
values for an enum?
I have a file called secure.properties
the following information:
authorization-api-context=http://localhost:8099/
mongo-db-name=secure
defaul-countries="COL;ARG;PER"
and I would like to create an enum with the default countries, for example:
public enum DefaultCountries {
COL("COL", "Colombia"),
ARG("ARG", "Argentina"),
PER("PER", "Perú");
...
See if this works for you:
You need a properties file with the properties as if you were using them in an enum:
constants.enum:
Now you import the class as static:
Usage example:
English reference .