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

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

package org.bidib.wizard.model.status;

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

public enum ServoPortStatus implements BidibStatus {
    // @formatter:off
    START(ServoPortEnum.START, "start"), TEST(ServoPortEnum.TEST, "test");
    // @formatter:on

    private final ServoPortEnum type;

    private final String key;

    ServoPortStatus(ServoPortEnum type, String key) {
        this.type = type;
        this.key = key;
    }

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

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

    public static ServoPortStatus valueOf(ServoPortEnum type) {
        ServoPortStatus result = null;

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

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

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

    @Override
    public ServoPortStatus[] getValues() {
        return new ServoPortStatus[] { START, TEST };
    }

    @Override
    public ServoPortStatus[] getMacroValues() {
        return new ServoPortStatus[] { START };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy