Search in sources :

Example 1 with ExitPointSpec

use of org.yakindu.sct.model.stext.stext.ExitPointSpec in project statecharts by Yakindu.

the class STextValidationModelUtils method getExitSpecSortedTransitions.

/**
 * Sorts the given elements in transition without and with
 * {@link ExitPointSpec}s
 *
 * @param elements
 *            - list of transitions to sort
 * @return an array with the sorted elements. The first index contains a
 *         list of the transitions without {@link ExitPointSpec}s. The
 *         second index contains a list of the transitions with
 *         {@link ExitPointSpec}s.
 */
public static List<Transition>[] getExitSpecSortedTransitions(List<Transition> elements) {
    @SuppressWarnings("unchecked") final List<Transition>[] transitions = new ArrayList[2];
    // first list contains Transitions without exit spec
    transitions[0] = new ArrayList<Transition>();
    // second list contains Transitions with exit spec
    transitions[1] = new ArrayList<Transition>();
    for (Transition transition : elements) {
        boolean hasExitSpec = false;
        for (ReactionProperty property : transition.getProperties()) {
            if (property instanceof ExitPointSpec) {
                transitions[1].add(transition);
                hasExitSpec = true;
                break;
            }
        }
        if (!hasExitSpec) {
            transitions[0].add(transition);
        }
    }
    return transitions;
}
Also used : ExitPointSpec(org.yakindu.sct.model.stext.stext.ExitPointSpec) ArrayList(java.util.ArrayList) Transition(org.yakindu.sct.model.sgraph.Transition) ArrayList(java.util.ArrayList) List(java.util.List) ReactionProperty(org.yakindu.sct.model.sgraph.ReactionProperty)

Example 2 with ExitPointSpec

use of org.yakindu.sct.model.stext.stext.ExitPointSpec in project statecharts by Yakindu.

the class STextValidationModelUtils method isDefaultExitTransition.

public static boolean isDefaultExitTransition(Transition transition) {
    boolean isDefault = false;
    List<ExitPointSpec> exits = getExitPointSpecs(transition.getProperties());
    if (!exits.isEmpty()) {
        for (ExitPointSpec exit : exits) {
            if (exit.getExitpoint().equalsIgnoreCase("default")) {
                isDefault = true;
            }
        }
    } else {
        isDefault = true;
    }
    return isDefault;
}
Also used : ExitPointSpec(org.yakindu.sct.model.stext.stext.ExitPointSpec)

Example 3 with ExitPointSpec

use of org.yakindu.sct.model.stext.stext.ExitPointSpec in project statecharts by Yakindu.

the class ExtractSubdiagramRefactoring method addExitPointSpec.

private void addExitPointSpec(Transition transition, Exit exitPoint) {
    EList<ReactionProperty> properties = transition.getProperties();
    ExitPointSpec exitPointSpec = StextFactory.eINSTANCE.createExitPointSpec();
    // A transition can only have one exit point so alter the existing
    for (ReactionProperty reactionProperty : properties) {
        if (reactionProperty instanceof ExitPointSpec) {
            exitPointSpec = (ExitPointSpec) reactionProperty;
        }
    }
    exitPointSpec.setExitpoint(exitPoint.getName());
    properties.add(exitPointSpec);
}
Also used : ExitPointSpec(org.yakindu.sct.model.stext.stext.ExitPointSpec) ReactionProperty(org.yakindu.sct.model.sgraph.ReactionProperty)

Example 4 with ExitPointSpec

use of org.yakindu.sct.model.stext.stext.ExitPointSpec in project statecharts by Yakindu.

the class STextValidationModelUtils method isNamedExitTransition.

/**
 * Validates if the a {@link Transition} has an {@link ExitPointSpec} with
 * the given name.
 *
 * @param transition
 *            - the transition to check
 * @param name
 *            - the name to check
 * @return {@code true} if the transition contains an ExitPointSpec with the
 *         name. Otherwise {@code false}.
 */
public static boolean isNamedExitTransition(Transition transition, String name) {
    boolean isNamedExitTransition = false;
    Iterator<ReactionProperty> propertyIt = transition.getProperties().iterator();
    while (propertyIt.hasNext() && !isNamedExitTransition) {
        ReactionProperty property = propertyIt.next();
        if (property instanceof ExitPointSpec) {
            isNamedExitTransition = name.equals(((ExitPointSpec) property).getExitpoint());
        }
    }
    return isNamedExitTransition;
}
Also used : ExitPointSpec(org.yakindu.sct.model.stext.stext.ExitPointSpec) ReactionProperty(org.yakindu.sct.model.sgraph.ReactionProperty)

Aggregations

ExitPointSpec (org.yakindu.sct.model.stext.stext.ExitPointSpec)4 ReactionProperty (org.yakindu.sct.model.sgraph.ReactionProperty)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Transition (org.yakindu.sct.model.sgraph.Transition)1