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

org.requirementsascode.FlowStep Maven / Gradle / Ivy

There is a newer version: 2.0
Show newest version
package org.requirementsascode;

import java.io.Serializable;
import java.util.Objects;
import java.util.Optional;

import org.requirementsascode.flowposition.FlowPosition;

/**
 * @author b_muth
 */
public abstract class FlowStep extends Step implements Serializable {
	private static final long serialVersionUID = -2926490717985964131L;

	private Flow flow;
	private FlowPosition flowPosition;
	private FlowStep previousStepInFlow;
	private Condition reactWhile;

	FlowStep(String stepName, Flow flow, Condition condition) {
		super(stepName, flow.getUseCase(), condition);
		this.flow = flow;
	}

	public Flow getFlow() {
		return flow;
	}

	public Optional getPreviousStepInFlow() {
		return Optional.ofNullable(previousStepInFlow);
	}

	void setPreviousStepInFlow(FlowStep previousStepInFlow) {
		this.previousStepInFlow = previousStepInFlow;
	}

	public FlowPosition getFlowPosition() {
		return flowPosition;
	}

	void setFlowPosition(FlowPosition flowPosition) {
		Objects.requireNonNull(flowPosition);

		this.flowPosition = flowPosition;
	}

	public void orAfter(FlowStep step) {
		setFlowPosition(flowPosition.orAfter(step));
	}

	public void setReactWhile(Condition reactWhileCondition) {
		this.reactWhile = reactWhileCondition;
		createLoop();
	}

	private void createLoop() {
		getFlowPosition().orAfter(this);
	}

	public Condition getReactWhile() {
		return reactWhile;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy