package com.goafanti.message.enums;

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

public enum  SubjectType {
	/** 运营 **/
	YUN_YING(0,"YUN_YING"),
	/** 客户 **/
	KE_HU(1,"KE_HU"),
	/** 推荐 **/
	TUI_JIAN(2,"TUI_JIAN"),
	/** 没有定义 **/
	NO_DEFINITION(null,"NO_DEFINITION");
	private SubjectType(Integer typeCode, String typeName) {
		this.typeCode = typeCode;
		this.typeName = typeName;
	}
	
	private Integer	typeCode;

	private String	typeName;

	public Integer getTypeCode() {
		return typeCode;
	}

	public void setTypeCode(Integer typeCode) {
		this.typeCode = typeCode;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public SubjectType getField(Integer code){
		if(subjects.containsKey(code)) return subjects.get(code);
		return NO_DEFINITION;
	}
	
	public static Map<Integer,SubjectType> subjects = new HashMap<Integer, SubjectType>();
	
	static {
		for(SubjectType value : SubjectType.values()){
			subjects.put(value.getTypeCode(), value);
		}
	}
	
	public static boolean containsType(int code){
		return subjects.containsKey(code);
	}
}
