org.bidib.wizard.model.status.SoundPortStatus Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bidibwizard-model Show documentation
Show all versions of bidibwizard-model Show documentation
jBiDiB BiDiB Wizard Model POM
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 };
}
}