package org.well.well.AlarmEnumDTO;

/**
 * Created by admin on 2017/4/6.
 */
public enum WaterMeterAlarmEnum {
    NO_DATA("设备异常",-1),
    NORMAL("正常",0),
    WaterMeterFail("远传水表采集失败",1);
    // 成员变量
    private String name;
    private int index;
    // 构造方法
    private WaterMeterAlarmEnum(String name, int index){
        this.name=name;
        this.index=index;
    }

    public int getIndex() {
        return index;
    }

    public static WaterMeterAlarmEnum getByIndex(String index) {
        try {
            for (WaterMeterAlarmEnum 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;
    }
}
