package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum ConsultantType {
	
	DL(0,"专利代理人"), 
	ZL(1,"专利顾问"),
	BQ(2,"版权顾问"),
	SB(3,"商标顾问");
	

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

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

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

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

	public static ConsultantType getStatus(String code) {
		if (StringUtils.isNumeric(code)) {
			return getStatus(Integer.parseInt(code));
		}
		return DL;
	}

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

	private Integer	code;
	private String	desc;

	public Integer getCode() {
		return this.code;
	}

	public String getDesc() {
		return this.desc;
	}
	
	public static Integer getValue(Integer value) {  
		ConsultantType[] businessModeEnums = values();  
        for (ConsultantType businessModeEnum : businessModeEnums) {  
            if (businessModeEnum.getCode().equals(value)) {  
                return businessModeEnum.getCode();  
            }  
        }  
        return null;  
    }   
      
    public static String getDesc(Integer value) {  
    	ConsultantType[] businessModeEnums = values();  
        for (ConsultantType businessModeEnum : businessModeEnums) {  
            if (businessModeEnum.getCode().equals(value)) {  
                return businessModeEnum.getDesc();  
            }  
        }  
        return null;  
    }  

}
