package com.goafanti.order.enums; import java.util.HashMap; import java.util.Map; public enum ChangeState { /** 正常 **/ UNCHANGE(0,"UNCHANGE"), /** 变更中 **/ CHANGING(1,"CHANGING"), /** 变更完成 **/ CHANGED(2,"CHANGED"), /** 无效 **/ INVALID(10, "INVALID"); private ChangeState(Integer code, String desc) { this.code = code; this.desc = desc; } private static Map status = new HashMap(); static { for (ChangeState value : ChangeState.values()) { status.put(value.getCode(), value); } } public static ChangeState getStatus(Integer code) { if (containsType(code)) { return status.get(code); } return INVALID; } public static boolean containsType(Integer code) { return status.containsKey(code); } private Integer code; private String desc; public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } }