package com.ycl.jxkg.enums; import java.util.HashMap; import java.util.Map; public enum ExamPaperTypeEnum { Fixed(1, "固定试卷"), Random(2, "随机试卷"), RandomOrder(3, "随序试卷"); private final Integer code; private final String name; ExamPaperTypeEnum(Integer code, String name) { this.code = code; this.name = name; } private static Map keyMap = new HashMap<>(); static { for (ExamPaperTypeEnum item : ExamPaperTypeEnum.values()) { keyMap.put(item.getCode(), item); } } public static ExamPaperTypeEnum fromCode(Integer code) { return keyMap.get(code); } public Integer getCode() { return code; } public String getName() { return name; } }