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

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

/**
 * @Description: 京东 入账状态 已入账
 * @Author: linjinyu
 * @CreateDate: 2021/10/21 上午10:42
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/10/21 上午10:42
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum JdWereAccountedStateEnum {

	UNKNOW(-1,"UNKNOW"),
	已入账(1, "已入账"),
	;

	private Integer key;
	private String  desc;

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

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

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

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

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