/** * Specifies that this pattern is optional for a final match of the pattern * sequence to happen. * * @return The same pattern as optional. * @throws MalformedPatternException if the quantifier is not applicable to this pattern. */ public Pattern<T, F> optional() { checkIfPreviousPatternGreedy(); quantifier.optional(); return this; }
/** * Specifies that the pattern can occur between from and to times. * * @param from number of times matching event must appear at least * @param to number of times matching event must appear at most * @return The same pattern with the number of times range applied * * @throws MalformedPatternException if the quantifier is not applicable to this pattern. */ public Pattern<T, F> times(int from, int to) { checkIfNoNotPattern(); checkIfQuantifierApplied(); this.quantifier = Quantifier.times(quantifier.getConsumingStrategy()); if (from == 0) { this.quantifier.optional(); from = 1; } this.times = Times.of(from, to); return this; }
/** * Specifies that this pattern is optional for a final match of the pattern * sequence to happen. * * @return The same pattern as optional. * @throws MalformedPatternException if the quantifier is not applicable to this pattern. */ public Pattern<T, F> optional() { quantifier.optional(); return this; }
/** * Specifies that this pattern is optional for a final match of the pattern * sequence to happen. * * @return The same pattern as optional. * @throws MalformedPatternException if the quantifier is not applicable to this pattern. */ public Pattern<T, F> optional() { checkIfPreviousPatternGreedy(); quantifier.optional(); return this; }
/** * Specifies that this pattern is optional for a final match of the pattern * sequence to happen. * * @return The same pattern as optional. * @throws MalformedPatternException if the quantifier is not applicable to this pattern. */ public Pattern<T, F> optional() { checkIfPreviousPatternGreedy(); quantifier.optional(); return this; }
/** * Specifies that the pattern can occur between from and to times. * * @param from number of times matching event must appear at least * @param to number of times matching event must appear at most * @return The same pattern with the number of times range applied * * @throws MalformedPatternException if the quantifier is not applicable to this pattern. */ public Pattern<T, F> times(int from, int to) { checkIfNoNotPattern(); checkIfQuantifierApplied(); this.quantifier = Quantifier.times(quantifier.getConsumingStrategy()); if (from == 0) { this.quantifier.optional(); from = 1; } this.times = Times.of(from, to); return this; }
/** * Specifies that the pattern can occur between from and to times. * * @param from number of times matching event must appear at least * @param to number of times matching event must appear at most * @return The same pattern with the number of times range applied * * @throws MalformedPatternException if the quantifier is not applicable to this pattern. */ public Pattern<T, F> times(int from, int to) { checkIfNoNotPattern(); checkIfQuantifierApplied(); this.quantifier = Quantifier.times(quantifier.getConsumingStrategy()); if (from == 0) { this.quantifier.optional(); from = 1; } this.times = Times.of(from, to); return this; }