package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum PatentAnnualFeeStatus {
	UNPAID(0, "未缴年登印费"),
	PAID(1, "已缴年登印费"),
	OTHER(2, "其他");

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

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

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

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

	public static PatentAnnualFeeStatus 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;
	}


}
