package com.gk.hotwork.specialWork.enums; import java.util.HashMap; import java.util.Map; public enum WorkProcessWarningTypeEnum { CHECK((byte)1,"检查"), DETECTION((byte)2,"检测"), ; public byte code; public String value; WorkProcessWarningTypeEnum(Byte code, String value) { this.code = code; this.value = value; } static Map map; static { map = new HashMap<>(); for (WorkProcessWarningTypeEnum e : WorkProcessWarningTypeEnum.values()) { map.put(e.code, e); } } public static WorkProcessWarningTypeEnum parse(Byte code) { return map.get(code); } }