package org.well.well.AlarmEnumDTO;

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

    NO_DATA("设备异常", -1),
    NORMAL("状态正常", 0),
    FireHydrantOpenAlarm("消防栓开盖报警", 1),
    FireHydrantWaterAlarm("消防栓出水报警", 2),
    FireHydrantDataAlarm("消防栓数据异常", 3);

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

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

    public int getIndex() {
        return index;
    }

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

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

    public String getName() {
        return name;
    }
}
