How do I find a subset of an enum in Java?
I have an enum as shown below:
public enum DatacenterEnum {
ABC, PQR, LTR;
// this tells my current local datacenter enum
private static final DatacenterEnum ourLocation = findCurrentLocation();
}
Now I want to find a list of remote data centers. As an example, suppose if ourLocation
is ABC, then the list REMOTE_DATACENTER, or it can be an EnumSet (I will repeat this later) should have PQR and LTR, similarly for other combinations. What's the best way to do this?
+3
source to share