public enum CustomerYesEnum { Yes("是", 1), No("否", 0), ; CustomerYesEnum(String code, Integer desc) { this.code = code; this.desc = desc; } private String code; private Integer desc; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public Integer getDesc() { return desc; } public static Integer getDescByCode(String code) { for (CustomerYesEnum value : CustomerYesEnum.values()) { if (value.code.equals(code)) { return value.desc; } } return null; } public static CustomerYesEnum getStatusByCode(String code) { for (CustomerYesEnum value : CustomerYesEnum.values()) { if (value.code.equals(code)) { return value; } } return null; } }
java创建枚举类
最新推荐文章于 2024-07-30 03:17:03 发布