Enum with getting subset I just wrote this but I'm not sure if this is good practice.  Can someone give me advice as to whether it's good or how I can do better or even it's bad code?

The point is that I need a sub List-array-set of the enum.  The SubType.ELSE shall have another name in reality (I know that was a bad choice, but it's for pointing it out). 

public enum ContentType {
    TITLE("$$title$$",SubType.MAIL),
    BODY("$$body$$",SubType.MAIL),
    MESSAGE("$$message$$",SubType.MAIL),
    EVENTS("$$events$$",SubType.ELSE);

    private final String replaceWord;
    private final SubType subType;

    private ContentType(String replaceWord, SubType subType ) {
        this.replaceWord = replaceWord;
        this.subType = subType;
    }

    public String getReplaceWord() {
        return replaceWord;
    }

    private SubType getSubType() {
        return subType;
    }

    public static List&lt;ContentType&gt; values(SubType subType) {
        List&lt;ContentType&gt; subList = new ArrayList&lt;ContentType&gt;();
        for (ContentType type : ContentType.values()) {
            if (type.getSubType() == subType) {
                subList.add(type);
            }
        }
        return subList;
    }
}

enum SubType {
    MAIL,
    ELSE;
}
I suggest two changes to values(SubType):


Return a Set instead of a List.
Prepare all the possible results at class-loading time, so that values(SubType) could be accomplished by a simple lookup.  The code is slightly more complicated, but the runtime performance should be better.




private static final Map&lt;SubType, Set&lt;ContentType&gt;&gt; BY_SUBTYPE;
static {
    BY_SUBTYPE = new HashMap&lt;SubType, Set&lt;ContentType&gt;&gt;();
    for (SubType subType : SubType.values()) {
        BY_SUBTYPE.put(subType, new TreeSet&lt;ContentType&gt;());
    }
    for (ContentType type : ContentType.values()) {
        BY_SUBTYPE.get(type.getSubType()).add(type);
    }
    for (SubType subType : BY_SUBTYPE.keySet()) {
        // Make Set&lt;ContentType&gt; values immutable
        BY_SUBTYPE.put(subType, Collections.unmodifiableSet(BY_SUBTYPE.get(subType)));
    }
}

public static Set&lt;ContentType&gt; values(SubType subType) {
    // Returns an unmodifiable view of a SortedSet
    return BY_SUBTYPE.get(subType);
}