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

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

/**
 * @author kite
 * @version 1.0
 * @date 2019/8/10
 */
public enum CommonOrderCompletStateEnum {

	已完成(1, "已完成"),
	未完成(2, "未完成"),
	已作废(3, "已作废"),
	;

	private Integer key;
	private String  desc;

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

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

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

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