package cn.superdesk.uniorder.common.enums.lnss;

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

/**
 * @author Carl Lee
 * @date 2019-08-24 13:42
 */
public enum ReportDateTypeEnum {
    YEAR(1,"年"),
    QUARTER(2,"季度"),
    MONTHLY(3,"月"),
    DATE(4,"日"),
    ;

    private Integer key;
    private String desc;

    ReportDateTypeEnum(int key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public int getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(int key) {
        for (ReportDateTypeEnum c : ReportDateTypeEnum.values()) {
            if (c.key == key) {
                return c.getDesc();
            }
        }
        return null;
    }

    private static final Map<Integer, ReportDateTypeEnum> LOOKUP = new HashMap<>();

    static {
        for(ReportDateTypeEnum s : EnumSet.allOf(ReportDateTypeEnum.class)) {
            LOOKUP.put(s.getKey(), s);
        }
    }

    /**
     * 方向查找枚举类
     * @param key
     * @return
     */
    public static ReportDateTypeEnum get(Integer key) {
        return LOOKUP.get(key);
    }
}
