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


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

/**
 * @Description: 订单退单 单主体 双主体 情况
 * @Author: linjinyu
 * @CreateDate: 2021/10/21 下午3:22
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/10/21 下午3:22
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum CommonOrderSubjectSituationEnum {

	UNKNOW(-1, "UNKNOW"),
	单主体(1, "单主体"),
	双主体(2, "双主体"),

	;

	private Integer key;
	private String  desc;

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

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

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

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

	public static CommonOrderSubjectSituationEnum getByDesc(String desc) {
		for (CommonOrderSubjectSituationEnum stateEnum : CommonOrderSubjectSituationEnum.values()) {
			if (stateEnum.desc.equals(desc)) {
				return stateEnum;
			}
		}
		return CommonOrderSubjectSituationEnum.UNKNOW;
	}
}
