package click.kamil.examples.statemachine.inheritanceextrafunctionsstate3;

import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
import org.springframework.statemachine.config.configurers.ExternalTransitionConfigurer;
import org.springframework.statemachine.config.configurers.StateConfigurer;

class G2StateMachineConfiguration extends AbstractGStateMachineConfiguration {
    @Override
    protected void addAdditionalStates(StateConfigurer<States, Events> states) {
        states.state(States.STATE_EXTRA_1);
        states.state(States.STATE_EXTRA_2);
    }

    @Override
    protected void addAdditionalCancellationTransitions(StateMachineTransitionConfigurer<States, Events> transitions) {
        addAllCancellationTransitionsForSource(transitions, States.STATE_EXTRA_1);
        addAllCancellationTransitionsForSource(transitions, States.STATE_EXTRA_2);
    }

    @Override
    protected void addAdditionalTransitions(ExternalTransitionConfigurer<States, Events> transitions) throws Exception {
        transitions
                .and()
                .withExternal().event(Events.EVENT_1_2)
                .source(States.STATE3)
                .target(States.STATE_EXTRA_1)
                .and()
                .withExternal().event(Events.EVENT_1_3)
                .source(States.STATE_EXTRA_1)
                .target(States.STATE_EXTRA_2);
    }
}
