package com.goafanti.order.enums; import java.util.HashMap; import java.util.Map; public enum OrderChannel { /** 手机APP **/ APP(0,"APP"), /** 门户网站 **/ PORTAL(1,"PORTAL"), /** 线下支付 **/ SCENE(2,"SCENE"), /** 无效 **/ INVALID(10, "INVALID"); private OrderChannel(Integer code, String desc) { this.code = code; this.desc = desc; } private static Map channels = new HashMap(); static { for (OrderChannel value : OrderChannel.values()) { channels.put(value.getCode(), value); } } public static OrderChannel getStatus(Integer code) { if (containsType(code)) { return channels.get(code); } return INVALID; } public static boolean containsType(Integer code) { return channels.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; } }