package com.inspect.patrol.contants;

import lombok.Getter;

@Getter
public enum LinkageDeviceType {
    CONTROL("遥控", 0),
    SIGNAL("遥信", 1),
    MEASURE("遥测", 2);

    private String name;
    private int value;

    LinkageDeviceType(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public static LinkageDeviceType getInstance(String name) {
        LinkageDeviceType[] valueList = values();

        for (LinkageDeviceType value : valueList) {
            if (value.getName().equals(name)) {
                return value;
            }
        }

        return null;
    }

    public static LinkageDeviceType getInstance(int v) {
        LinkageDeviceType[] valueList = values();
        for (LinkageDeviceType value : valueList) {
            if (value.getValue() == v) {
                return value;
            }
        }

        return null;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setValue(int value) {
        this.value = value;
    }
}
