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

io.serverlessworkflow.api.states.OperationState Maven / Gradle / Ivy

There is a newer version: 7.0.0-alpha5.1
Show newest version

package io.serverlessworkflow.api.states;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonValue;
import io.serverlessworkflow.api.actions.Action;
import io.serverlessworkflow.api.end.End;
import io.serverlessworkflow.api.error.Error;
import io.serverlessworkflow.api.filters.StateDataFilter;
import io.serverlessworkflow.api.interfaces.State;
import io.serverlessworkflow.api.timeouts.TimeoutsDefinition;
import io.serverlessworkflow.api.transitions.Transition;


/**
 * This state allows one or more functions to run in sequence or in parallel without waiting for any event.
 * 
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
    "actionMode",
    "actions",
    "usedForCompensation"
})
public class OperationState
    extends DefaultState
    implements Serializable, State
{

    /**
     * Specifies whether functions are executed in sequence or in parallel.
     * (Required)
     * 
     */
    @JsonProperty("actionMode")
    @JsonPropertyDescription("Specifies whether functions are executed in sequence or in parallel.")
    @NotNull
    private OperationState.ActionMode actionMode;
    /**
     * Actions Definitions
     * (Required)
     * 
     */
    @JsonProperty("actions")
    @JsonPropertyDescription("Actions Definitions")
    @Valid
    @NotNull
    private List actions = new ArrayList();
    /**
     * If true, this state is used to compensate another state. Default is false
     * 
     */
    @JsonProperty("usedForCompensation")
    @JsonPropertyDescription("If true, this state is used to compensate another state. Default is false")
    private boolean usedForCompensation = false;
    private final static long serialVersionUID = -4679881670025324625L;

    /**
     * No args constructor for use in serialization
     * 
     */
    public OperationState() {
    }

    /**
     * 
     * @param actionMode
     * @param name
     * @param type
     * @param actions
     */
    public OperationState(OperationState.ActionMode actionMode, List actions, java.lang.String name, DefaultState.Type type) {
        super(name, type);
        this.actionMode = actionMode;
        this.actions = actions;
    }

    /**
     * Specifies whether functions are executed in sequence or in parallel.
     * (Required)
     * 
     */
    @JsonProperty("actionMode")
    public OperationState.ActionMode getActionMode() {
        return actionMode;
    }

    /**
     * Specifies whether functions are executed in sequence or in parallel.
     * (Required)
     * 
     */
    @JsonProperty("actionMode")
    public void setActionMode(OperationState.ActionMode actionMode) {
        this.actionMode = actionMode;
    }

    public OperationState withActionMode(OperationState.ActionMode actionMode) {
        this.actionMode = actionMode;
        return this;
    }

    /**
     * Actions Definitions
     * (Required)
     * 
     */
    @JsonProperty("actions")
    public List getActions() {
        return actions;
    }

    /**
     * Actions Definitions
     * (Required)
     * 
     */
    @JsonProperty("actions")
    public void setActions(List actions) {
        this.actions = actions;
    }

    public OperationState withActions(List actions) {
        this.actions = actions;
        return this;
    }

    /**
     * If true, this state is used to compensate another state. Default is false
     * 
     */
    @JsonProperty("usedForCompensation")
    public boolean isUsedForCompensation() {
        return usedForCompensation;
    }

    /**
     * If true, this state is used to compensate another state. Default is false
     * 
     */
    @JsonProperty("usedForCompensation")
    public void setUsedForCompensation(boolean usedForCompensation) {
        this.usedForCompensation = usedForCompensation;
    }

    public OperationState withUsedForCompensation(boolean usedForCompensation) {
        this.usedForCompensation = usedForCompensation;
        return this;
    }

    @Override
    public OperationState withId(java.lang.String id) {
        super.withId(id);
        return this;
    }

    @Override
    public OperationState withName(java.lang.String name) {
        super.withName(name);
        return this;
    }

    @Override
    public OperationState withType(DefaultState.Type type) {
        super.withType(type);
        return this;
    }

    @Override
    public OperationState withEnd(End end) {
        super.withEnd(end);
        return this;
    }

    @Override
    public OperationState withStateDataFilter(StateDataFilter stateDataFilter) {
        super.withStateDataFilter(stateDataFilter);
        return this;
    }

    @Override
    public OperationState withMetadata(Map metadata) {
        super.withMetadata(metadata);
        return this;
    }

    @Override
    public OperationState withTransition(Transition transition) {
        super.withTransition(transition);
        return this;
    }

    @Override
    public OperationState withOnErrors(List onErrors) {
        super.withOnErrors(onErrors);
        return this;
    }

    @Override
    public OperationState withCompensatedBy(java.lang.String compensatedBy) {
        super.withCompensatedBy(compensatedBy);
        return this;
    }

    @Override
    public OperationState withTimeouts(TimeoutsDefinition timeouts) {
        super.withTimeouts(timeouts);
        return this;
    }

    public enum ActionMode {

        SEQUENTIAL("sequential"),
        PARALLEL("parallel");
        private final java.lang.String value;
        private final static Map CONSTANTS = new HashMap();

        static {
            for (OperationState.ActionMode c: values()) {
                CONSTANTS.put(c.value, c);
            }
        }

        private ActionMode(java.lang.String value) {
            this.value = value;
        }

        @Override
        public java.lang.String toString() {
            return this.value;
        }

        @JsonValue
        public java.lang.String value() {
            return this.value;
        }

        @JsonCreator
        public static OperationState.ActionMode fromValue(java.lang.String value) {
            OperationState.ActionMode constant = CONSTANTS.get(value);
            if (constant == null) {
                throw new IllegalArgumentException(value);
            } else {
                return constant;
            }
        }

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy