package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum PatentCategoryStatus {
	
	OTHER(0, "其他"),
	UTILITY(1, "实用新型专利"),
	DESIGN(2, "外观设计型专利"),
	INVENTION(3, "发明型专利");

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

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

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

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

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

	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;
	}

}
