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/8
 */
public enum DeliveryStaffTypeEnum {
    /**
     * 项目配送员
     */
    PROJECT(1,"项目配送员"),
    /**
     * 商户配送员"
     */
    SALE(2,"商户配送员");

    private Integer key;
    private String desc;

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

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

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

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