| | |
| | | import java.util.Map; |
| | | |
| | | public enum VisibilityEnum { |
| | | Private(1,"PRIVATE", "只有老师自己能看"), |
| | | Public(2,"PUBLIC", "所有人能看"); |
| | | Integer code; |
| | | Private("1","Private", "只有老师自己能看"), |
| | | Public("2","Public", "所有人能看"); |
| | | String code; |
| | | String name; |
| | | String description; |
| | | |
| | | VisibilityEnum(Integer code,String name, String description) { |
| | | VisibilityEnum(String code,String name, String description) { |
| | | this.code = code; |
| | | this.name = name; |
| | | this.description = description; |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | public Integer getCode() { |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(Integer code) { |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | private static final Map<Integer, VisibilityEnum> keyMap = new HashMap<>(); |
| | | private static final Map<String, VisibilityEnum> keyMap = new HashMap<>(); |
| | | |
| | | static { |
| | | for (VisibilityEnum item : VisibilityEnum.values()) { |
| | | keyMap.put(item.getCode(), item); |
| | | } |
| | | } |
| | | public static VisibilityEnum fromCode(Integer code) { |
| | | public static VisibilityEnum fromCode(String code) { |
| | | return keyMap.get(code); |
| | | } |
| | | |