I would like to be able to define an Enum class that would include another Enum as well as its own values. For example, :
public enum A {
A1, A2, A3;
}
public enum B{
B1, B2, ...(somehow define references to all values in enum A)
}
such that any values contained in enum B must be either defined initself (such as B1, B2) or any values of enum A.
Thanks,
解决方案
Such that B is the union of A and B? That's not possible without B extending A, which is not supported in java. The way to proceed is to create an enum which contains the combined values of A and B, e.g.,
enum C {
A1, A2, A3, B1, B2;
}