package com.goafanti.common.enums;

import org.apache.commons.lang3.StringUtils;

import java.util.*;

public enum OfficialPatentType {
	SQ(0,"申请"),
	BG(1,"变更"),
	ZR(14,"转让"),
	FS(2,"复审"),
	YXQ(3,"优先权"),
	HFQQQ(4,"恢复请求权"),
	WXXGQQF(5,"无效宣告请求费"),
	QZXKQQF(6,"强制许可请求费"),
	QZXKSYCJQQF(7,"强制许可使用裁决请求费"),
	DLYSFYHS(8,"登录、印刷费、印花税"),
	FJF11(9,"要求附加费从第 11 项起每项增收"),
	FJF31(10,"说明书附加费从第 31 页起每页增收"),
	FJF301(11,"从第 301 页起每页增收"),
	ZZF(12,"中止费"),
	JSBGF(13,"检索报告费"),

	NOT(99,"未知");
	
	private OfficialPatentType(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

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

	
	public static String getValueByCode(Integer code){
        for(OfficialPatentType o:OfficialPatentType.values()){
            if(code.equals(o.getCode())){
                return o.getDesc();
            }
        }
        return  NOT.getDesc();
    }
	public static OfficialPatentType getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return NOT;
	}

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

	public static List<Map<Object, Object>> getStatus() {
		List<Map<Object, Object>> list=new ArrayList<Map<Object,Object>>();
		for(OfficialPatentType o:OfficialPatentType.values()){
			Map<Object, Object> map=new LinkedHashMap<Object, Object>();
			if (o.getCode()!=OfficialPatentType.NOT.getCode()) {
				map.put("id", o.getCode());
				map.put("name", o.getDesc());
				list.add(map);
			}
		}
		return list;
	}
	
	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}

	private Integer	code;
	private String	desc;

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	} 

}
