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

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

/**
 * @author kite
 * @version 1.0
 * @date 2019/8/24
 */
public enum DeliveryTypeEnum {

    SEND(1,"送货上门"),

    NO_SEND(2,"到店自提"),

    UNIFIED_DELIVERY(3,"统一配送"),

    ;

    private Integer key;
    private String desc;

    DeliveryTypeEnum(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 (DeliveryTypeEnum c : DeliveryTypeEnum.values()) {
            if (c.key == key) {
                return c.getDesc();
            }
        }
        return null;
    }

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

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

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