org.bidib.wizard.model.status.ServoPortStatus 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.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 };
}
}