com.bnorm.infinite.builders.StateMachineBuilderBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinite Show documentation
Show all versions of infinite Show documentation
Infinite - A hierarchical finite state machine for Java
The newest version!
package com.bnorm.infinite.builders;
import com.bnorm.infinite.StateMachine;
import com.bnorm.infinite.StateMachineFactory;
import com.bnorm.infinite.StateMachineStructure;
/**
* The base implementation of a state machine builder.
*
* @param the class type of the states.
* @param the class type of the events.
* @param the class type of the context.
* @author Brian Norman
* @since 1.0.0
*/
public class StateMachineBuilderBase implements StateMachineBuilder {
/** The state machine structure. */
private final StateMachineStructure structure;
/** The state machine builder state machine factory. */
private final StateMachineFactory stateMachineFactory;
/** The state machine builder state builder factory. */
private final StateBuilderFactory stateBuilderFactory;
/**
* Constructs a new state machine builder from the specified state machine structure, state machine factory, and
* state builder factory.
*
* @param structure the state machine structure.
* @param stateMachineFactory the factory used to create the state machine.
* @param stateBuilderFactory the factory used to create state builders.
*/
protected StateMachineBuilderBase(StateMachineStructure structure,
StateMachineFactory stateMachineFactory,
StateBuilderFactory stateBuilderFactory) {
this.structure = structure;
this.stateMachineFactory = stateMachineFactory;
this.stateBuilderFactory = stateBuilderFactory;
}
@Override
public StateBuilder configure(S state) {
return stateBuilderFactory.create(structure, state);
}
@Override
public StateMachine build(S starting, C context) {
return stateMachineFactory.create(structure, starting, context);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy