org.bidib.wizard.model.status.SwitchPortStatus 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
The newest version!
package org.bidib.wizard.model.status;
import org.bidib.jbidibc.messages.enums.SwitchPortEnum;
public enum SwitchPortStatus implements BidibStatus {
// @formatter:off
ON(SwitchPortEnum.ON, "on"), OFF(SwitchPortEnum.OFF, "off"), TEST(SwitchPortEnum.TEST, "test");
// @formatter:on
private final SwitchPortEnum type;
private final String key;
SwitchPortStatus(SwitchPortEnum type, String key) {
this.type = type;
this.key = key;
}
@Override
public SwitchPortEnum getType() {
return type;
}
@Override
public String getKey() {
return key;
}
public static SwitchPortStatus valueOf(SwitchPortEnum type) {
SwitchPortStatus result = null;
for (SwitchPortStatus e : values()) {
if (e.type == type) {
result = e;
break;
}
}
if (result == null) {
throw new IllegalArgumentException("cannot map " + type + " to a switch port status");
}
return result;
}
public static SwitchPortStatus fromString(String type) {
SwitchPortStatus result = null;
for (SwitchPortStatus e : values()) {
if (e.key.equalsIgnoreCase(type)) {
result = e;
break;
}
}
if (result == null) {
throw new IllegalArgumentException("cannot map " + type + " to a switch port status");
}
return result;
}
@Override
public SwitchPortStatus[] getValues() {
return new SwitchPortStatus[] { ON, OFF, TEST };
}
@Override
public SwitchPortStatus[] getMacroValues() {
return new SwitchPortStatus[] { ON, OFF };
}
}