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

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

/**
 * @Description: 是否启用:0-禁用;1-启用;
 * @Author: linjinyu
 * @CreateDate: 2020/12/17 上午11:48
 * @UpdateUser: linjinyu
 * @UpdateDate: 2020/12/17 上午11:48
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum CommonEnabledEnum {

	禁用(0, "禁用"),
	启用(1, "启用"),
	;

	private Integer key;
	private String  desc;

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

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

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

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