package com.goafanti.report.enums;

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

public enum TimeType {
	WEEKLY(0, "本周"),
	MONTH(1, "本月"),
	QTR(2, "本季"),
	YEAR(3, "本年"),
	ZS(4, "自选");

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

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

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

	@SuppressWarnings("unlikely-arg-type")
	public static TimeType getField(String code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return ZS;
	}

	@SuppressWarnings("unlikely-arg-type")
	public static boolean containsType(String code) {
		return status.containsKey(code);
	}

	private Integer	code;
	private String	desc;

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}
}
