package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum InterestType {
	ACHIEVEMENT(0, "成果"),
	DEMAND(1, "需求"),
	EXPERTS(2, "专家"),
	POLICY(3,"政策"),
	UNAUDITED(4,"活动"),
	PROJECT(5,"项目"),
	OTHER(6, "其他"),
	COUNSELOR(7,"咨询师");

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

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

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

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

	public static InterestType 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;
	}

}

