org.bidib.wizard.api.model.function.RandomDelayFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bidibwizard-api Show documentation
Show all versions of bidibwizard-api Show documentation
jBiDiB BiDiB Wizard API POM
package org.bidib.wizard.api.model.function;
import org.bidib.jbidibc.exchange.lcmacro.LcMacroPointType;
import org.bidib.jbidibc.exchange.lcmacro.RandomDelayPoint;
import org.bidib.wizard.model.status.BidibStatus;
public class RandomDelayFunction extends SystemFunction implements Delayable {
private int maximumValue = 255;
public RandomDelayFunction() {
super(null, KEY_RANDOM_DELAY);
}
public int getMaximumValue() {
return maximumValue;
}
public void setMaximumValue(int maximumValue) {
this.maximumValue = maximumValue;
}
public String getDebugString() {
return "@" + getMaximumValue() + " RandomDelay";
}
@Override
public LcMacroPointType toLcMacroPoint() {
RandomDelayPoint delayPoint = new RandomDelayPoint();
delayPoint.setRandomDelayActionType(getMaximumValue());
return delayPoint;
}
@Override
public int getDelay() {
return getMaximumValue();
}
@Override
public void setDelay(int delay) {
setMaximumValue(delay);
}
public static class RandomDelayFunctionBuilder extends RandomDelayFunctionBuilderBase {
public static RandomDelayFunctionBuilder randomDelayFunction() {
return new RandomDelayFunctionBuilder();
}
public RandomDelayFunctionBuilder() {
super(new RandomDelayFunction());
}
public RandomDelayFunction build() {
return getInstance();
}
}
static class RandomDelayFunctionBuilderBase> {
private RandomDelayFunction instance;
protected RandomDelayFunctionBuilderBase(RandomDelayFunction aInstance) {
instance = aInstance;
}
protected RandomDelayFunction getInstance() {
return instance;
}
@SuppressWarnings("unchecked")
public GeneratorT withDelay(int aValue) {
instance.setDelay(aValue);
return (GeneratorT) this;
}
}
}