package click.kamil.enterprise.machines.user;

import click.kamil.enterprise.core.AbstractStateMachine;
import click.kamil.enterprise.core.TransitionContext;
import org.springframework.stereotype.Component;

@Component
public class UserStateMachine extends AbstractStateMachine<UserState, UserEvent> {

    public UserStateMachine() {
        super(UserState.GUEST);
    }

    @Override
    public String getMachineType() {
        return "USER";
    }

    @Override
    protected void configureTransitions() {
        addTransition(UserEvent.REGISTER, UserState.REGISTERED);
        addTransition(UserEvent.VERIFY, UserState.VERIFIED);
    }

    @Override
    protected void onTransition(UserState from, UserState to, UserEvent event, TransitionContext<?> context) {
        System.out.println("[User] " + context.getUserId() + " is now " + to);
    }
}
