package com.goafanti.order.enums; import java.util.HashMap; import java.util.Map; public enum LiquidationNewState { /** 首付待付清 **/ WAIT_PAY_FIRST_BALANCE(0,"首付待付清"), /** 尾款待付清 **/ WAIT_PAY_LAST_BALANCE(1,"尾款待付清"), /** 已付清 **/ ALREADY_PAY(2,"已付清"), /** 退款待确认 **/ REBATESQUAN(3,"退款待确认"), FULL_REFUND(4,"全部退款"), /** 无效 **/ INVALID(10, "INVALID"); private LiquidationNewState(Integer code, String desc) { this.code = code; this.desc = desc; } private static Map status = new HashMap(); static { for (LiquidationNewState value : LiquidationNewState.values()) { status.put(value.getCode(), value); } } public static LiquidationNewState getStatus(Integer code) { if (containsType(code)) { return status.get(code); } return INVALID; } public static String getValueByCode(Integer code){ for(LiquidationNewState liquidationNewState:LiquidationNewState.values()){ if(code.equals(liquidationNewState.getCode())){ return liquidationNewState.getDesc(); } } return null; } 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; } }