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

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

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2022/3/18 1:36 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/3/18 1:36 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum CommonBeRelatedEnum {

    级联(0, "级联"),
    失联(1, "失联"),
    ;

    private Integer key;
    private String desc;

    CommonBeRelatedEnum(Integer key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public Integer getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(Integer key) {
        for (CommonBeRelatedEnum c : CommonBeRelatedEnum.values()) {
            if (c.key.equals(key)) {
                return c.getDesc();
            }
        }
        return null;
    }

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

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

    public static CommonBeRelatedEnum get(Integer key) {
        return LOOKUP.get(key);
    }
}
