package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum AchievementTransferMode {
	
	FULLTRANSFER(0, "完全转让"),
	PERMISSIONTRANSFER(1,"许可转让"),
	TECHNOLOGYSHARES(2,"技术入股"),
	EXCLUSIVETECHNOLOGYSHARES(3, "5年独占许可转让"),
	OTHER(4, "其他");

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

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

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

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

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

}
