Ejemplo n.º 1
0
 private Integer getPolymorphicSize(FTransition transition) {
   final Set<String> keys = transition.getPolymorphicKey();
   final Map<String, Integer> variableSizes = rlts.getDomainVariableSpace().sizes();
   Integer size = 1;
   for (final String key : keys) {
     size = size * variableSizes.get(key);
   }
   return size;
 }
Ejemplo n.º 2
0
 private FTransition getEvaluator(FGuard originalGuard, FState preEvaluation) {
   if (originalGuard == null || originalGuard.getEvaluator() == null) {
     return null;
   }
   FState pastState = preEvaluation;
   while (pastState != null) {
     final List<Transition> outgoings = pastState.getOutgoings();
     for (final Transition t : outgoings) {
       final FTransition transition = (FTransition) t;
       final FAction pastAction = transition.getFAction();
       if (pastAction != null) {
         if (originalGuard.getEvaluator().getFAction().equals(pastAction)) {
           return transition;
         }
       }
     }
     if (pastState.getIncoming() != null) {
       pastState = (FState) pastState.getIncoming().getSource();
     } else {
       pastState = null;
     }
   }
   throw new FatalFwitterException("evaluator transition not found");
 }
Ejemplo n.º 3
0
  @Override
  protected Boolean visitFTransition(FTransition transition) {
    final Set<FState> sources = statesStack.pop();
    final Set<FState> targets = new HashSet<FState>();
    final FGuard originalGuard = (FGuard) transition.getGuard();

    final Integer size = this.getPolymorphicSize(transition);
    int suffix = 0;
    for (final FState source : sources) {
      if (transition.isPolymorphic()) {
        for (int i = 0; i < size; i++) {
          final FTransition newTransition = transition.getUnconnectedCopy();
          newTransition.setSource(source);
          newTransition.setGuardEvaluator(getEvaluator(originalGuard, source));
          final FState target = new FState(transition.getTarget().getName() + suffix++);
          newTransition.setTarget(target);
          targets.add(target);
        }
      } else {
        final FTransition newTransition = transition.getUnconnectedCopy();
        newTransition.setGuardEvaluator(getEvaluator(originalGuard, source));
        newTransition.setSource(source);
        if (transition.isSelfLoop()) {
          newTransition.setTarget(source);
        } else {
          final FState target = new FState(transition.getTarget().getName() + suffix++);
          newTransition.setTarget(target);
          targets.add(target);
        }
      }
    }
    statesStack.push(sources);
    statesStack.push(targets);
    return true;
  }