
org.bidib.wizard.comm.SpeedSteps Maven / Gradle / Ivy
package org.bidib.wizard.comm;
import org.bidib.jbidibc.core.enumeration.SpeedStepsEnum;
import org.bidib.wizard.locale.Resources;
public enum SpeedSteps implements BidibStatus {
// @formatter:off
DCC14(14, "14", SpeedStepsEnum.DCC14), DCC28(28, "28", SpeedStepsEnum.DCC28), DCC128(126, "128",
SpeedStepsEnum.DCC128);
// @formatter:on
private final int steps;
private final String label;
private final String key;
private final SpeedStepsEnum type;
SpeedSteps(int steps, String key, SpeedStepsEnum type) {
this.steps = steps;
this.key = key;
this.label = Resources.getString(SpeedSteps.class, key);
this.type = type;
}
public int getSteps() {
return steps;
}
public SpeedStepsEnum getType() {
return type;
}
public String getKey() {
return key;
}
public String toString() {
return label;
}
public static SpeedSteps valueOf(SpeedStepsEnum type) {
SpeedSteps result = null;
for (SpeedSteps e : values()) {
if (e.type == type) {
result = e;
break;
}
}
if (result == null) {
throw new IllegalArgumentException("cannot map " + type + " to a speed step");
}
return result;
}
public static SpeedSteps valueOf(int speedSteps) {
SpeedSteps result = null;
// change 128 --> 126
if (speedSteps == 128) {
speedSteps = 126;
}
for (SpeedSteps e : values()) {
if (e.steps == speedSteps) {
result = e;
break;
}
}
if (result == null) {
throw new IllegalArgumentException("cannot map " + speedSteps + " to a speed step");
}
return result;
}
@Override
public BidibStatus[] getValues() {
return new BidibStatus[] { DCC14, DCC28, DCC128 };
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy