package com.headstartech.scheelite;

import com.google.common.base.Optional;

import java.util.Map;
import java.util.Set;

/**
 * The configuration of the state machine (states and their super state, transitions and initial transitions).
 */
public class StateMachineConfiguration<T, U> {

    private final StateTree<T, U> stateTree;
    private final TransitionMap<T, U> transitionMap;

    StateMachineConfiguration(StateTree<T, U> stateTree, TransitionMap<T, U> transitionMap) {
        this.stateTree = stateTree;
        this.transitionMap = transitionMap;
    }

    /**
     * Gets the states in the state machine
     *
     * @return the states
     *
     * @see com.headstartech.scheelite.State
     */
    public Set<State<T, U>> getStates() { return stateTree.getStates(); }

    /**
     * Gets the transitions in the state machine
     *
     * @return the transitions
     *
     * @see com.headstartech.scheelite.Transition
     */
    public Set<Transition<T, U>> getTransitions() { return transitionMap.getTransitions(); }

    /**
     * Gets the initial transition in the state machine
     *
     * @return the initial transitions
     *
     * @see com.headstartech.scheelite.Transition
     */
    public Set<InitialTransition<T, U>> getInitialTransitions() { return null; }


    /**
     * Gets the super state of the specified {@link com.headstartech.scheelite.State}.
     *
     * @param state
     * @return the super state
     */
    public State<T, U> getSuperState(State<T, U> state) {
        Optional<State<T, U>> superState = stateTree.getParent(state);
        if(superState.isPresent()) {
            return superState.get();
        } else {
            return null;
        }
    }

    public State<T, U> getRootState() { return stateTree.getRootState(); }

}

@@ -1285,20 +1285,53 @@
  return 
-null
+transitionMap.getInitialTransitions()
 ; %7D%0A%0A%0A  
@@ -1476,24 +1476,79 @@
  super state
+ or %3Ccode%3Enull%3C/code%3E if the argument is the root state
 %0A     */%0A   

return initial transitions in conf