package com.gkhy.safePlatform.safeCheck.enums; import java.util.HashMap; import java.util.Map; public enum UserTypeEnum { ADMIN((byte) 1, "超级管理员"), MANAGER((byte) 2, "管理员"), STAFF((byte)3,"普通员工"); UserTypeEnum(byte code, String desc) { this.code = code; this.desc = desc; } byte code; String desc; public byte getCode() { return code; } public String getDesc() { return desc; } static Map map; static { map = new HashMap<>(); for (UserTypeEnum userTypeEnum : UserTypeEnum.values()) { map.put(userTypeEnum.getCode(), userTypeEnum); } } public static UserTypeEnum parse(Byte code) { return map.get(code); } }