My question is: how to create a list of all constants of specified class?
Is this possible in an easy way? Or I just need to write my own (somewhat simple) solution for this?
Let me present some code:
public class StateOfSomeProcess {
private final static String STATE_A = "State A";
private final static String STATE_B = "State B";
private final static String STATE_C = "State C";
private final static String STATE_D = "State D";
public StateOfSomeProcess() {...}
public List<String> getListOfAllStates() {
List<String> list = new ArrayList<String>();
...
//I wish there was a method like this:
//list = this.getAllConstantsFromClass();
...
return list;
}
}
I know about enum
s, but it does not seem to fit my needs.
Please feel free to let me know if my question is unclear or needs improvement.