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

io.microlam.hsm.impl.StateBuilder Maven / Gradle / Ivy

package io.microlam.hsm.impl;

import io.microlam.hsm.Action;
import io.microlam.hsm.EntryExitAction;
import io.microlam.hsm.Hsm;

public class StateBuilder {

	BasicHsm hsm;
	String name;
	String parent;
	String initialChild;
	
	Action inner;
	EntryExitAction entry, exit;
	
	public StateBuilder(BasicHsm hsm) {
		this.hsm = hsm;
	}
	
	public StateBuilder name(String name) {
		this.name = name;
		return this;
	}
	
	public StateBuilder entry(EntryExitAction entry) {
		this.entry = entry;
		return this;
	}

	public StateBuilder exit(EntryExitAction exit) {
		this.exit = exit;
		return this;
	}

	public StateBuilder inner(Action inner) {
		this.inner = inner;
		return this;
	}

	public StateBuilder parent(String parent) {
		this.parent = parent;
		return this;
	}
	
	public StateBuilder initialChild(String initialChild) {
		this.initialChild = initialChild;
		return this;
	}

	public StateBuilder build() {
		hsm.registerState(new BasicState(hsm, name, parent, initialChild, entry, exit, inner));
		return new StateBuilder(hsm);
	}
	
	public Hsm buildAndStop() {
		hsm.registerState(new BasicState(hsm, name, parent,initialChild, entry, exit, inner));
		return hsm;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy