package com.mortals.xhx.common.code;

import java.util.LinkedHashMap;
import java.util.Map;

public enum TimeUnitEnum {
    /** 小时 */
    HOUR(0, "小时"),
    /** 日 */
    DAY(1, "每日"),
    /** 月 */
    MONTH(2, "月"),
    /** 年 */
    YEAR(3, "年");

    private int value;
    private String desc;

    TimeUnitEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public int getValue() {
        return this.value;
    }

    public String getDesc() {
        return desc;
    }


	public static TimeUnitEnum getByValue(int value) {
        for (TimeUnitEnum yesNo : TimeUnitEnum.values()) {
            if (yesNo.getValue() == value) {
                return yesNo;
            }
        }
        return null;
    }

    public static Map<String,String> getEnumMap(int... eItem) {
        Map<String,String> resultMap= new LinkedHashMap<String,String>();
        for (TimeUnitEnum item : TimeUnitEnum.values()) {
            try{
                boolean hasE = false;
                for (int e : eItem){
                    if(item.getValue()==e){
                        hasE = true;
                        break;
                    }
                }
                if(!hasE){
                    resultMap.put(item.getValue()+"", item.getDesc());
                }
            }catch(Exception ex){
            }
        }
        return resultMap;
    }

}
