package com.goafanti.message.enums;

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

public enum ConsumerType {
	/** 行业 **/
	INDUSTRY(0,"INDUSTRY"),
	/** 社会标签 **/
	SOCIETY_TAG(1,"SOCIETY_TAG"),
	/** 省市区 **/
	LOCATION(2,"LOCATION"),
	LOCATION_PROVINCE(21,"PROVINCE"),
	LOCATION_CITY(22,"CITY"),
	LOCATION_AREA(23,"AREA"),
	/** 公司 **/
	COMPANY(3,"COMPANY"),
	/** 角色 **/
	ROLE(4,"ROLE"),
	/** 用户散户 **/
	USER_RETAIL(5,"USER_RETAIL"),
	/** 客户散户 **/
	CUSTOMER_RETAIL(6,"CUSTOMER_RETAIL"),
	/** 个人客户 **/
	PERSON_CUSTOMER_RETAIL(61,"PERSON_CUSTOMER_RETAIL"),
	/** 单位客户 **/
	ORGANIZATION_CUSTOMER_RETAIL(62,"ORGANIZATION_CUSTOMER_RETAIL"),
	/** 没有定义 **/
	NO_DEFINITION(null,"NO_DEFINITION");
	private ConsumerType(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 ConsumerType getField(Integer code){
		if(subjects.containsKey(code)) return subjects.get(code);
		return NO_DEFINITION;
	}
	
	public static Map<Integer,ConsumerType> subjects = new HashMap<Integer, ConsumerType>();
	
	static {
		for(ConsumerType value : ConsumerType.values()){
			subjects.put(value.getTypeCode(), value);
		}
	}
	
	public static boolean containsType(int code){
		return subjects.containsKey(code);
	}
}
