I want to define few String constants inside an Enum value and access these constant in context with in same enum value. For e.g. Below is my enum definition:
public enum EventType {
QUERY_UPDATE {
public String QUERY_LIST = "QUERY_LIST"; //this variable is not accessible in client code.
},
SINGLE_RESULT_HANDLE {
public static final String SINGLE_QUERY_OBJECT = "SINGLE_QUERY_OBJECT"; //this variable is not accessible in client code.
public static final String SINGLE_QUERY_RESULT = "SINGLE_QUERY_RESULT";
},
COLLATED_RESULT_HANDLE {
enum Keys{ //compiler error : The member enum Keys can only be defined inside a top-level class or interface or in a static context.
COLLATED_RESULT_LIST,
}
};
}
In my code, where I want to use these enum values :
//client code.
GenericEvent resultEvent = new GenericEvent(EventType.QUERY_UPDATE);
resultEvent.addContextProperty(EventType.QUERY_UPDATE.QUERY_LIST, "abcd"); //LINE 2
Now in LINE 2 (first argument) above, I want to specify the String Constant which belongs only to EventType.QUERY_UPDATE. But there seems no way to get this done. Please suggest how to resolve this.