package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum LectureDynamicType {
	UNDYNAMIC(0, "科技明星页面不展示"), DYNAMIC(1, "科技明星页面展示"), OTHER(2, "其他");

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

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

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

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

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

}
