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