/**
* 埋点模块枚举
* @author huang
*/
public enum ModelEnum {
PROCESS_CONTROL("流程管控", 10),
TASK_CENTER("任务中心", 20),
QHSE("QHSE管理", 30),
DATA_TRANSFER("数字化移交", 40),
INFO_SHARE("信息共享", 50),
APP_SYSTEM("应用系统", 60);
/**
* 根据 code 返回 name
*/
public static String getNameByCode(Integer code){
for (ModelEnum value : ModelEnum.values()) {
if (value.getCode() == code.intValue()) {
return value.getName();
}
}
return null;
}
/**
* 校验 name 合法性
*/
public static boolean checkName(String name){
for (ModelEnum value : ModelEnum.values()) {
if (name.contentEquals(value.getName())){
return true;
}
}
return false;
}
private String name;
private Integer code;
ModelEnum(String name, Integer code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
}
标签:code,java,name,ModelEnum,枚举,使用,return,public,String
From: https://www.cnblogs.com/hangychn/p/17151607.html