public enum PlayerType {
ANONYMOUS(1, "AnonymousPatron"),
PATRON(2, "Patron"),
UNREGISTERED(3, "UnregisteredPlayer");
private int code;
private String description;
private static final Map<Integer, PlayerType> codeToEnum = new HashMap<Integer, PlayerType>();
static {
for (PlayerType PlayerType : values()) {
codeToEnum.put(PlayerType.getCode(), PlayerType);
}
}
PlayerType(int code, String description) {
this.code = code;
this.description = description;
}
public int getCode() {
return code;
}
public String getDescription() {
return description;
}
public static PlayerType fromCode(int code){
return codeToEnum.get( code );
}
}
Emun 简单实例
最新推荐文章于 2024-02-27 15:50:20 发布