这是我班的早期构造:
public class Player {
public enum Tech {
NONE(EnumSet.noneOf(Tech.class)),
VEGETATION(EnumSet.of(NONE)),
LIVESTOCK(EnumSet.of(NONE)),
STRAWBERRIES(EnumSet.of(VEGETATION)),
BIODOME(EnumSet.of(STRAWBERRIES)),
BIOMASS(EnumSet.of(VEGETATION, LIVESTOCK));
private final Set<Tech> prerequisites;
Tech(Set<Tech> prerequisites) {
this.prerequisites = prerequisites;
}
}
private Set<Tech> techsKnown;
public Player() {
techsKnown = EnumSet.of(Tech.NONE);
}
}
我希望 NONE 有一个空集。最好的方法是什么?