package org.well.well.AlarmEnumDTO;

/**
 * Created by admin on 2017/4/6.
 */
public enum AlarmEnum {

    Normal("正常", 0),
    OVER_THRESH1("一级告警", 1),
    OVER_THRESH2("二级告警", 2),
    OVER_THRESH3("三级告警", 3);


    // 成员变量
    private String name;
    private int index;

    // 构造方法
    private AlarmEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public int getIndex() {
        return this.index;
    }

    public String getName() {
        return this.name;
    }

    public static AlarmEnum getByIndex(String index) {
        try {
            for (AlarmEnum temp : values()) {
                if (temp.index == Integer.parseInt(index)) {
                    return temp;
                }
            }
        } catch (Exception e) {
        }
        return null;
    }

    //覆盖方法
    @Override
    public String toString() {
        return this.name;
    }


}
