private void checkIfNoGroupPattern() { if (this instanceof GroupPattern) { throw new MalformedPatternException("Option not applicable to group pattern"); } }
private static void checkPattern(boolean condition, Object errorMessage) { if (!condition) { throw new MalformedPatternException(String.valueOf(errorMessage)); } }
/** * Checks if the given name is already used or not. If yes, it * throws a {@link MalformedPatternException}. * * @param name The name to be checked. */ public void checkNameUniqueness(String name) { if (usedNames.contains(name)) { throw new MalformedPatternException("Duplicate pattern name: " + name + ". Names must be unique."); } usedNames.add(name); }
private void checkIfQuantifierApplied() { if (!quantifier.hasProperty(Quantifier.QuantifierProperty.SINGLE)) { throw new MalformedPatternException("Already applied quantifier to this Pattern. " + "Current quantifier is: " + quantifier); } }
private void checkIfNoNotPattern() { if (quantifier.getConsumingStrategy() == ConsumingStrategy.NOT_FOLLOW || quantifier.getConsumingStrategy() == ConsumingStrategy.NOT_NEXT) { throw new MalformedPatternException("Option not applicable to NOT pattern"); } }
private void checkIfPreviousPatternGreedy() { if (previous != null && previous.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY)) { throw new MalformedPatternException("Optional pattern cannot be preceded by greedy pattern"); } }
/** * Applies a stop condition for a looping state. It allows cleaning the underlying state. * * @param untilCondition a condition an event has to satisfy to stop collecting events into looping state * @return The same pattern with applied untilCondition */ public Pattern<T, F> until(IterativeCondition<F> untilCondition) { Preconditions.checkNotNull(untilCondition, "The condition cannot be null"); if (this.untilCondition != null) { throw new MalformedPatternException("Only one until condition can be applied."); } if (!quantifier.hasProperty(Quantifier.QuantifierProperty.LOOPING)) { throw new MalformedPatternException("The until condition is only applicable to looping states."); } ClosureCleaner.clean(untilCondition, true); this.untilCondition = untilCondition; return this; }
/** * Check pattern after match skip strategy. */ private void checkPatternSkipStrategy() { if (afterMatchSkipStrategy.getPatternName().isPresent()) { String patternName = afterMatchSkipStrategy.getPatternName().get(); Pattern<T, ?> pattern = currentPattern; while (pattern.getPrevious() != null && !pattern.getName().equals(patternName)) { pattern = pattern.getPrevious(); } // pattern name match check. if (!pattern.getName().equals(patternName)) { throw new MalformedPatternException("The pattern name specified in AfterMatchSkipStrategy " + "can not be found in the given Pattern"); } } }
/** * Compiles the given pattern into a {@link NFAFactory}. The NFA factory can be used to create * multiple NFAs. */ void compileFactory() { if (currentPattern.getQuantifier().getConsumingStrategy() == Quantifier.ConsumingStrategy.NOT_FOLLOW) { throw new MalformedPatternException("NotFollowedBy is not supported as a last part of a Pattern!"); } checkPatternNameUniqueness(); checkPatternSkipStrategy(); // we're traversing the pattern from the end to the beginning --> the first state is the final state State<T> sinkState = createEndingState(); // add all the normal states sinkState = createMiddleStates(sinkState); // add the beginning state createStartState(sinkState); }
private void checkIfNoGroupPattern() { if (this instanceof GroupPattern) { throw new MalformedPatternException("Option not applicable to group pattern"); } }
private void checkIfNoGroupPattern() { if (this instanceof GroupPattern) { throw new MalformedPatternException("Option not applicable to group pattern"); } }
private static void checkPattern(boolean condition, Object errorMessage) { if (!condition) { throw new MalformedPatternException(String.valueOf(errorMessage)); } }
/** * Checks if the given name is already used or not. If yes, it * throws a {@link MalformedPatternException}. * * @param name The name to be checked. */ public void checkNameUniqueness(String name) { if (usedNames.contains(name)) { throw new MalformedPatternException("Duplicate pattern name: " + name + ". Names must be unique."); } }
private static void checkPattern(boolean condition, Object errorMessage) { if (!condition) { throw new MalformedPatternException(String.valueOf(errorMessage)); } }
private static void checkPattern(boolean condition, Object errorMessage) { if (!condition) { throw new MalformedPatternException(String.valueOf(errorMessage)); } }
/** * Checks if the given name is already used or not. If yes, it * throws a {@link MalformedPatternException}. * * @param name The name to be checked. */ public void checkNameUniqueness(String name) { if (usedNames.contains(name)) { throw new MalformedPatternException("Duplicate pattern name: " + name + ". Names must be unique."); } usedNames.add(name); }
/** * Checks if the given name is already used or not. If yes, it * throws a {@link MalformedPatternException}. * * @param name The name to be checked. */ public void checkNameUniqueness(String name) { if (usedNames.contains(name)) { throw new MalformedPatternException("Duplicate pattern name: " + name + ". Names must be unique."); } usedNames.add(name); }
private void checkIfQuantifierApplied() { if (!quantifier.hasProperty(Quantifier.QuantifierProperty.SINGLE)) { throw new MalformedPatternException("Already applied quantifier to this Pattern. " + "Current quantifier is: " + quantifier); } } }
private void checkIfQuantifierApplied() { if (!quantifier.hasProperty(Quantifier.QuantifierProperty.SINGLE)) { throw new MalformedPatternException("Already applied quantifier to this Pattern. " + "Current quantifier is: " + quantifier); } }
private void checkIfQuantifierApplied() { if (!quantifier.hasProperty(Quantifier.QuantifierProperty.SINGLE)) { throw new MalformedPatternException("Already applied quantifier to this Pattern. " + "Current quantifier is: " + quantifier); } }