public enum XXXEnum{
Customer(1,"customer");
XXXEnum(int code,String value){
this.code = code;
this.value = value;
}
private String value;
private int code;
public String getValue() {
return value;
}
public int getCode() {
return code;
}
public static XXXEnum codeOf(int code){
for(XXXEnum xxxEnum : values()){
if(xxxEnum.getCode() == code){
return xxxEnum;
}
}
throw new RuntimeException("没有找到对应的枚举");
}
}
java中根据int值来对应Enum
最新推荐文章于 2024-08-01 04:38:05 发布