package com.gkhy.safePlatform.account.enums.schedule; import java.util.HashMap; import java.util.Map; public enum TimeTypeEnum { REST((byte) 1, "休息"), WORK((byte) 2, "工作"), ; TimeTypeEnum(byte code, String value) { this.code = code; this.value = value; } byte code; String value; public byte getCode() { return code; } public String getValue() { return value; } static Map map; static { map = new HashMap<>(); for (TimeTypeEnum statusEnum : TimeTypeEnum.values()) { map.put(statusEnum.code, statusEnum); } } public static TimeTypeEnum parse(Byte code) { return map.get(code); } }