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:44
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/10/21 上午10:44
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum JdPayTypeEnum {

	UNKNOW(-1, "UNKNOW"),
	金采支付(1, "金采支付"),
	;

	private Integer key;
	private String  desc;

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

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

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

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

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