package com.gkhy.safePlatform.emergency.enums; import java.util.HashMap; import java.util.Map; public enum EmergencySuppliesStatusEnum { STATUS_ONE((byte) 1, "完好"), STATUS_TWO((byte) 2, "维修"); private Byte code; private String value; EmergencySuppliesStatusEnum(Byte code, String value) { this.code = code; this.value = value; } public Byte getCode() { return code; } public void setCode(Byte code) { this.code = code; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } // 转换成为 MAP, 对外提供查询和遍历功能 public static Map toMap() { Map map = new HashMap(); for (EmergencySuppliesStatusEnum teamLevelEnum : EmergencySuppliesStatusEnum.values()) { map.put(teamLevelEnum.getCode(), teamLevelEnum); } return map; } public static EmergencySuppliesStatusEnum getByCode(Byte code){ return toMap().get(code); } }