package cn.superdesk.uniorder.common.queue.block;

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

/**
 * @Description: 定义任务的优先级 TaskPriorityEnum ETaskPriority(此命名还是算)
 * LOW < DEFAULT < HIGH
 * @Author: linjinyu
 * @CreateDate: 2021/9/9 下午3:45
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/9/9 下午3:45
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum TaskPriorityEnum {

	NICE_TO_HAVE(0, "优先级-随"),
	LOW(1, "优先级-低"),
	MIDDLE(2, "优先级-中"),
	HIGH(3, "优先级-高"),

	;

	private Integer key;
	private String  desc;

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

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

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

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