package com.goafanti.common.enums;

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

public enum UserFields {
	MOBILE("mobile", "手机号"),
	TYPE("type", "用户类别"),
	UNITNAME("unitName", "公司名称"),
	
	OTHER("", "未知参数");
	
	private String	code;
	private String	desc;
	
	private static Map<String, UserFields> status = new HashMap<String, UserFields>();
	
	private UserFields(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}
	
	static {
		for (UserFields value : UserFields.values()) {
			status.put(value.getCode(), value);
		}
	}
	
	public static UserFields getField(String code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}
	
	public static String getFieldDesc(String code) {
		return getField(code).getDesc();
	}

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

	public String getDesc() {
		return desc;
	}

}
