package org.well.well.AlarmEnumDTO;

/**
 * Created by admin on 2017/4/6.
 */
public enum WellPlusAlarmEnum {
    NO_DATA("设备异常", -1),
    NORMAL("心跳", 0),
    WellPlusOpenAlarm("井盖开盖报警", 1),
    WellPlusLevelAlarm("液位超限报警", 2),
    WellPlusUnknown("未知异常", 3);

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

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

    public int getIndex() {
        return index;
    }

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

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

    public String getName() {
        return name;
    }
}
