The language itself makes it impossible to create subsets of the enumeration. First of all, this will lead to the defeat of the purpose of the transfer - to have a certain set of values ββfor a given domain.
What you can do: Define another suitable enumeration for this domain and provide reasonable cross-mappings. To get an idea:
public enum WORKDAY { MONDAY(WEEKDAY.MONDAY), TUESDAY(WEEKDAY.TUESDAY), WEDNESDAY(WEEKDAY.WEDNESDAY), THURSDAY(WEEKDAY.THURSDAY), FRIDAY(WEEKDAY.FRIDAY); final public WEEKDAY weekday; WORKDAY(WEEKDAY wd){ this.weekday = wd; } static WORKDAY convertWeekday(WEEKDAY weekday){
The good thing: the calling conversion method must deal with these values ββthat are not displayable. Your method remains clean.
source share