All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.model.status.InputPortStatus Maven / Gradle / Ivy

There is a newer version: 2.0.26
Show newest version
package org.bidib.wizard.model.status;

import org.bidib.jbidibc.messages.enums.InputPortEnum;

public enum InputPortStatus implements BidibStatus {
    // @formatter:off
    ON(InputPortEnum.ON, "on"), OFF(InputPortEnum.OFF, "off");
    // @formatter:on

    private final InputPortEnum type;

    private final String key;

    InputPortStatus(InputPortEnum type, String key) {
        this.type = type;
        this.key = key;
    }

    @Override
    public InputPortEnum getType() {
        return type;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String toString() {
        return type.toString();
    }

    public static InputPortStatus valueOf(InputPortEnum type) {
        InputPortStatus result = null;

        for (InputPortStatus e : values()) {
            if (e.type == type) {
                result = e;
                break;
            }
        }
        if (result == null) {
            throw new IllegalArgumentException("cannot map " + type + " to an input port status");
        }
        return result;
    }

    public static InputPortStatus fromString(String type) {
        InputPortStatus result = null;

        for (InputPortStatus e : values()) {
            if (e.key.equalsIgnoreCase(type)) {
                result = e;
                break;
            }
        }
        if (result == null) {
            throw new IllegalArgumentException("cannot map " + type + " to a input port status");
        }
        return result;
    }

    @Override
    public InputPortStatus[] getValues() {
        return new InputPortStatus[] { ON, OFF };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy