我正在寻找像这样的基本枚举......
public enum SessionState {
WAITING(true), VOTING(true), PREPARING(false), PLAYING(false), ENDING(false);
boolean newPlayersJoin;
private SessionState(boolean newPlayersJoin){
this.newPlayersJoin = newPlayersJoin;
}
public boolean canNewPlayersJoin(){
return newPlayersJoin;
}
}
...然后是另一个具有相同值(等待、投票、准备、播放、结束)但具有更多功能的枚举。我想要一个没有额外方法的基本枚举的原因是某些方法依赖于不会包含在该 jar 文件中的函数(多模块项目)
我的另一个枚举看起来像这样
public enum SessionStateCopy {
WAITING(true, ... extra values), VOTING(true, ... extra values), PREPARING(false, ... extra values), PLAYING(false, ... extra values), ENDING(false, ... extra values);
boolean newPlayersJoin;
private SessionStateCopy(boolean newPlayersJoin, ... extra values){
this.newPlayersJoin = newPlayersJoin;
}
public boolean canNewPlayersJoin(){
return newPlayersJoin;
}
... extra methods
}