ru.yandex.qatools.camelot.common.CamelotFSMBuilder Maven / Gradle / Ivy
package ru.yandex.qatools.camelot.common;
import ru.yandex.qatools.fsm.Yatomata;
import ru.yandex.qatools.fsm.impl.YatomataImpl;
/**
* @author smecsia
*/
public class CamelotFSMBuilder {
final Class fsmClass;
public CamelotFSMBuilder(Class fsmClass) {
this.fsmClass = fsmClass;
}
public Yatomata build(T fsmInstance) {
return build(null, fsmInstance);
}
public Yatomata build(Object state, T fsmInstance) {
try {
if (state == null) {
return new YatomataImpl<>(fsmClass, fsmInstance);
}
return new YatomataImpl<>(fsmClass, fsmInstance, state);
} catch (Exception e) {
throw new RuntimeException("Could not initialize the FSM Engine for FSM " + fsmClass, e); //NOSONAR
}
}
}