I suggest you look for a different approach to achieving this. If you can think of a way of 'nesting' the states in the countries then you are going to have the issue of not having a single type for all states. You won't be able to have a state
variable that can be assigned a state of the US or a state of Argentina.
Here is an alternative model you could consider:
public interface State {
}
private enum UnitedStates implements State {
CALIFORNIA, ...;
}
private enum ArgentinaStates implements State {
BUENOS_AIRES, ...;
}
public enum Country {
SRILANKA(),
US(UnitedStates.values()),
ARGENTINA(ArgentinaStates.values());
Country(State... states) {
this.states = Arrays.toList(states);
}
private final List<State> states;
public List<State> getStates() {
return states;
}
}
Then you can do:
State state;
state = ArgentinaStates.BUENOS_AIRES;
state = UnitedStates.CALIFORNIA;