/** * This method extends the given condition with stop(until) condition if necessary. * The until condition needs to be applied only if both of the given conditions are not null. * * @param condition the condition to extend * @param untilCondition the until condition to join with the given condition * @param isTakeCondition whether the {@code condition} is for {@code TAKE} edge * @return condition with AND applied or the original condition */ private IterativeCondition<T> extendWithUntilCondition( IterativeCondition<T> condition, IterativeCondition<T> untilCondition, boolean isTakeCondition) { if (untilCondition != null && condition != null) { return new AndCondition<>(new NotCondition<>(untilCondition), condition); } else if (untilCondition != null && isTakeCondition) { return new NotCondition<>(untilCondition); } return condition; }
/** * This method extends the given condition with stop(until) condition if necessary. * The until condition needs to be applied only if both of the given conditions are not null. * * @param condition the condition to extend * @param untilCondition the until condition to join with the given condition * @param isTakeCondition whether the {@code condition} is for {@code TAKE} edge * @return condition with AND applied or the original condition */ private IterativeCondition<T> extendWithUntilCondition( IterativeCondition<T> condition, IterativeCondition<T> untilCondition, boolean isTakeCondition) { if (untilCondition != null && condition != null) { return new AndCondition<>(new NotCondition<>(untilCondition), condition); } else if (untilCondition != null && isTakeCondition) { return new NotCondition<>(untilCondition); } return condition; }
private void updateWithGreedyCondition( State<T> state, IterativeCondition<T> takeCondition) { for (StateTransition<T> stateTransition : state.getStateTransitions()) { stateTransition.setCondition( new AndCondition<>(stateTransition.getCondition(), new NotCondition<>(takeCondition))); } } }
private void updateWithGreedyCondition( State<T> state, IterativeCondition<T> takeCondition) { for (StateTransition<T> stateTransition : state.getStateTransitions()) { stateTransition.setCondition( new AndCondition<>(stateTransition.getCondition(), new NotCondition<>(takeCondition))); } } }
/** * @return The {@link IterativeCondition condition} for the {@code IGNORE} edge * that corresponds to the specified {@link Pattern}. It is applicable only for inner states of a complex * state like looping or times. */ @SuppressWarnings("unchecked") private IterativeCondition<T> getInnerIgnoreCondition(Pattern<T, ?> pattern) { switch (pattern.getQuantifier().getInnerConsumingStrategy()) { case STRICT: return null; case SKIP_TILL_NEXT: return new NotCondition<>((IterativeCondition<T>) pattern.getCondition()); case SKIP_TILL_ANY: return BooleanConditions.trueFunction(); } return null; }
/** * @return The {@link IterativeCondition condition} for the {@code IGNORE} edge * that corresponds to the specified {@link Pattern}. For more on strategy see {@link Quantifier} */ @SuppressWarnings("unchecked") private IterativeCondition<T> getIgnoreCondition(Pattern<T, ?> pattern) { switch (pattern.getQuantifier().getConsumingStrategy()) { case STRICT: return null; case SKIP_TILL_NEXT: return new NotCondition<>((IterativeCondition<T>) pattern.getCondition()); case SKIP_TILL_ANY: return BooleanConditions.trueFunction(); } return null; } }
break; case SKIP_TILL_NEXT: innerIgnoreCondition = new NotCondition<>((IterativeCondition<T>) pattern.getCondition()); break; case SKIP_TILL_ANY:
notNext.addIgnore(lastSink, new NotCondition<>(notCondition)); } else { notNext.addProceed(lastSink, new NotCondition<>(notCondition));
break; case SKIP_TILL_NEXT: innerIgnoreCondition = new NotCondition<>((IterativeCondition<T>) pattern.getCondition()); break; case SKIP_TILL_ANY:
notNext.addIgnore(lastSink, new NotCondition<>(notCondition)); } else { notNext.addProceed(lastSink, new NotCondition<>(notCondition));
? new AndCondition<>(proceedCondition, new NotCondition<>(untilCondition)) : proceedCondition); } else {
? new AndCondition<>(proceedCondition, new NotCondition<>(untilCondition)) : proceedCondition); } else {
notNext.addIgnore(lastSink, new NotCondition<>(notCondition)); } else { notNext.addProceed(lastSink, new NotCondition<>(notCondition));
break; case SKIP_TILL_NEXT: ignoreCondition = new NotCondition<>((IterativeCondition<T>) pattern.getCondition()); break; case SKIP_TILL_ANY:
? new AndCondition<>(proceedCondition, new NotCondition<>(untilCondition)) : proceedCondition); updateWithGreedyCondition(sinkState, getTakeCondition(currentPattern));
? new AndCondition<>(proceedCondition, new NotCondition<>(untilCondition)) : proceedCondition); updateWithGreedyCondition(sinkState, getTakeCondition(currentPattern));
break; case SKIP_TILL_NEXT: ignoreCondition = new NotCondition<>((IterativeCondition<T>) pattern.getCondition()); break; case SKIP_TILL_ANY: