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

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

There is a newer version: 2.0.29
Show newest version
package org.bidib.wizard.api.model.function;

import org.bidib.jbidibc.exchange.lcmacro.FlagActionType;
import org.bidib.jbidibc.exchange.lcmacro.FlagOperationType;
import org.bidib.jbidibc.exchange.lcmacro.FlagPoint;
import org.bidib.jbidibc.exchange.lcmacro.LcMacroPointType;
import org.bidib.wizard.api.model.Flag;
import org.bidib.wizard.model.status.FlagStatus;

public class FlagFunction extends SystemFunction {
    private Flag flag;

    public FlagFunction() {
        this(FlagStatus.CLEAR);
    }

    public FlagFunction(FlagStatus action) {
        this(action, null);
    }

    public FlagFunction(FlagStatus action, Flag flag) {
        super(action, KEY_FLAG);
        this.flag = flag;
    }

    public Flag getFlag() {
        return flag;
    }

    public void setFlag(Flag flag) {
        this.flag = flag;
    }

    public String getDebugString() {
        int id = 0;

        if (getFlag() != null) {
            id = getFlag().getId();
        }
        return "Flag" + getAction().name().substring(0, 1) + getAction().name().substring(1).toLowerCase() + id;
    }

    @Override
    public LcMacroPointType toLcMacroPoint() {
        FlagPoint flagPoint = new FlagPoint();
        FlagActionType flagActionType = new FlagActionType();
        flagActionType.setOperation(FlagOperationType.fromValue(getAction().getType().name()));
        flagActionType.setFlagNumber(getFlag().getId());
        flagPoint.setFlagActionType(flagActionType);
        return flagPoint;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy