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

ru.yandex.qatools.camelot.common.CamelotFSMBuilder Maven / Gradle / Ivy

There is a newer version: 2.5.4
Show newest version
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
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy