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

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

/**
 * @Description: 效用;1-有效的;2-无效的;3-不限;
 * @Author: linjinyu
 * @CreateDate: 2021/8/4 上午11:12
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/8/4 上午11:12
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum CommonEfficacyEnum {

	有效的(1, "有效的"),
	无效的(2, "无效的"),
	不限(3, "不限"),
	;

	private Integer key;
	private String  desc;

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

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

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

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