package com.mindskip.xzs.domain.enums; import java.util.HashMap; import java.util.Map; public enum QuestionSourceEnum { SINGLECHOICE(1,2), MULTIPLECHOICE(2,2), TRUEORFALSE(3,2); int type; int source; QuestionSourceEnum(int type, int source) { this.type = type; this.source = source; } private static final Map keyMap = new HashMap<>(); static { for (QuestionSourceEnum item : QuestionSourceEnum.values()) { keyMap.put(item.getType(), item.getSource()); } } public static Integer fromType(Integer type) { return keyMap.get(type); } public int getType() { return type; } public void setType(int type) { this.type = type; } public int getSource() { return source; } public void setSource(int source) { this.source = source; } }