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

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

package org.bidib.wizard.model.status;

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

public enum SoundPortStatus implements BidibStatus {
    // @formatter:off
    PLAY(SoundPortEnum.PLAY, "play"), STOP(SoundPortEnum.STOP, "stop"), TEST(SoundPortEnum.TEST, "test");
    // @formatter:on

    private final SoundPortEnum type;

    private final String key;

    SoundPortStatus(SoundPortEnum type, String key) {
        this.type = type;
        this.key = key;
    }

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

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

    public static SoundPortStatus valueOf(SoundPortEnum type) {
        SoundPortStatus result = null;

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

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

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

    @Override
    public SoundPortStatus[] getValues() {
        return new SoundPortStatus[] { PLAY, STOP, TEST };
    }

    @Override
    public SoundPortStatus[] getMacroValues() {
        return new SoundPortStatus[] { PLAY, STOP };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy