package cn.superdesk.uniorder.common.enums.lnss;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * 订单备注类型
 * @author Homan Liang
 * @date 2019/8/24
 */
public enum OrderRemarkTypeEnum {
    /**
     * 确认信息
     */
    CONFIRM(1,"确认信息"),
    /**
     * 取消信息
     */
    CANCEL(2,"取消信息");

    private Integer key;
    private String desc;

    OrderRemarkTypeEnum(int key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public int getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(int key) {
        for (OrderRemarkTypeEnum c : OrderRemarkTypeEnum.values()) {
            if (c.key == key) {
                return c.getDesc();
            }
        }
        return null;
    }

    private static final Map<Integer, OrderRemarkTypeEnum> LOOKUP = new HashMap<>();

    static {
        for(OrderRemarkTypeEnum s : EnumSet.allOf(OrderRemarkTypeEnum.class)) {
            LOOKUP.put(s.getKey(), s);
        }
    }

    /**
     * 方向查找枚举类
     * @param key
     * @return
     */
    public static OrderRemarkTypeEnum get(Integer key) {
        return LOOKUP.get(key);
    }
}
