枚举根据code 获取value

public enum RegistEnum {

ENG(1, "求职应聘"),
BUS(2, "业务交流"),
OTHER(3 ,"其它");

private final Integer code;
private final String value;

public Integer getCode() {
return code;
}

public String getValue() {
return value;
}

RegistEnum(Integer code, String value) {
this.code = code;
this.value = value;
}

public static String getValue(Integer code) {
for (RegistEnum value : RegistEnum.values()) {
if (value.getCode().equals(code)) {
return value.getValue();
}
}
return null;
}






}
posted @ 2022-12-22 14:15  桂长江  阅读(1077)  评论(0编辑  收藏  举报