package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;
	
public enum AchievementBargainingMode {
	
	NEGOTIABLE(0, "议价方式--面议"),
	FIXED_PRICE(1,"议价方式--定价"),
	OTHER(2, "其他");

	private AchievementBargainingMode(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	private static Map<Integer, AchievementBargainingMode> status = new HashMap<Integer, AchievementBargainingMode>();

	static {
		for (AchievementBargainingMode value : AchievementBargainingMode.values()) {
			status.put(value.getCode(), value);
		}
	}

	public static AchievementBargainingMode getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}

	public static AchievementBargainingMode getStatus(String code) {
		if (StringUtils.isNumeric(code)) {
			return getStatus(Integer.parseInt(code));
		}
		return OTHER;
	}

	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}

	private Integer	code;
	private String	desc;

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}


}
