I have the following enum in a Java class:
public enum Resolution {
RES_32 (32),
RES_64 (64);
private final int asInt;
private R
EnumSet may be helpful in this context. Given the following,
public enum Resolution {
RES_32(32),
RES_64(64),
RES_128(128),
RES_256(256);
public static Set deluxe = EnumSet.allOf(Resolution.class);
public static Set typical = EnumSet.range(RES_64, RES_128);
public static Set ecomomy = EnumSet.of(RES_32);
private final int asInt;
private Resolution(int asInt) {
this.asInt = asInt;
}
};
Suitably named sets may be used as shown below.
for (Resolution r : Resolution.deluxe) {
System.out.println(r.asInt);
}