package com.goafanti.patent.enums;

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

public enum PatentType {
	/**0实用新型 1发明专利 2外观专利**/
	 SYXX(0,"实用新型"),
	 /** 已分派 **/
	 FMZL(1,"发明专利"),
	 /** 材料已启动 **/
	 WGZL(2,"外观专利"),
	/** 无效 **/
	NOT(10, "无效");
	
	private PatentType(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

	static {
		for (PatentType value : PatentType.values()) {
			status.put(value.getCode(), value);
		}
	}
	public static PatentType getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return NOT;
	}
	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}
	public static String getValueByCode(Integer code){
        for(PatentType patentType:PatentType.values()){
            if(code.equals(patentType.getCode())){
                return patentType.getDesc();
            }
        }
        return  null;
    }
	
	public static Integer getCodeByDesc(String desc){
        for(PatentType patentType:PatentType.values()){
            if(desc.equals(patentType.getDesc())){
                return patentType.getCode();
            }
        }
        return  NOT.code;
    }
	
	public static String getCountStr() {
		StringBuffer str=new StringBuffer();
		for (PatentType value : PatentType.values()) {
			str.append(value.getCode()).append("=").append(value.getDesc()).append("，");
		}
		return str.substring(0, str.length()-1);
		
	}
	private Integer	code;
	private String	desc;
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	
}
