All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.api.model.function.RandomDelayFunction Maven / Gradle / Ivy

There is a newer version: 2.0.25
Show newest version
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;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy