package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum collectType {
	
	ACHIEVEMENT(0, "achievement"),//成果
	DMAND(1, "demand"),//1需求
	PATENT(2,"patent"),//2专利
	POLICY(3,"policy"),//3政策
	PROJECT(4,"jt_business_project"),//4项目
	EXPERT(5,"expert"),//5专家
	ADVISER(6,"adviser"),//6顾问
	NEWS(7,"news"),//7新闻
	LEGAL_ADVISER(9,"legal_adviser"),//9法律顾问
	KNOWLEDGE_BASE(10,"knowledge_base"),//10产品专栏
	OTHER(8, "");
	
	private collectType(Integer code, String desc) {
		this.code=code;
		this.desc=desc;
	}
	
	private static Map<Integer, collectType> status = new HashMap<Integer, collectType>();
	static {
		for (collectType value : collectType.values()) {
			status.put(value.getCode(), value);
		}
	}
	
	public static collectType getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}

	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}
	public static collectType getStatus(String code) {
		if (StringUtils.isNumeric(code)) {
			return getStatus(Integer.parseInt(code));
		}
		return OTHER;
	}
	
	public Integer getCode() {
		return code;
	}
	
	public String getDesc() {
		return desc;
	}
	
	private Integer	code;
	private String	desc;
	
	

}
