Github user dawidwys commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3761#discussion_r113377152
  
    --- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Quantifier.java
 ---
    @@ -18,51 +18,83 @@
     package org.apache.flink.cep.pattern;
     
     import java.util.EnumSet;
    +import java.util.Objects;
     
    -public enum Quantifier {
    -   ONE,
    -   ZERO_OR_MORE_EAGER(QuantifierProperty.LOOPING, 
QuantifierProperty.EAGER),
    -   ZERO_OR_MORE_COMBINATIONS(QuantifierProperty.LOOPING),
    -   ZERO_OR_MORE_EAGER_STRICT(QuantifierProperty.EAGER, 
QuantifierProperty.STRICT, QuantifierProperty.LOOPING),
    -   ZERO_OR_MORE_COMBINATIONS_STRICT(QuantifierProperty.STRICT, 
QuantifierProperty.LOOPING),
    -   ONE_OR_MORE_EAGER(
    -           QuantifierProperty.LOOPING,
    -           QuantifierProperty.EAGER,
    -           QuantifierProperty.AT_LEAST_ONE),
    -   ONE_OR_MORE_EAGER_STRICT(
    -           QuantifierProperty.STRICT,
    -           QuantifierProperty.LOOPING,
    -           QuantifierProperty.EAGER,
    -           QuantifierProperty.AT_LEAST_ONE),
    -   ONE_OR_MORE_COMBINATIONS(QuantifierProperty.LOOPING, 
QuantifierProperty.AT_LEAST_ONE),
    -   ONE_OR_MORE_COMBINATIONS_STRICT(
    -           QuantifierProperty.STRICT,
    -           QuantifierProperty.LOOPING,
    -           QuantifierProperty.AT_LEAST_ONE),
    -   TIMES(QuantifierProperty.TIMES),
    -   TIMES_STRICT(QuantifierProperty.TIMES, QuantifierProperty.STRICT),
    -   OPTIONAL;
    +public class Quantifier {
     
        private final EnumSet<QuantifierProperty> properties;
     
    -   Quantifier(final QuantifierProperty first, final QuantifierProperty... 
rest) {
    +   private Quantifier(final QuantifierProperty first, final 
QuantifierProperty... rest) {
                this.properties = EnumSet.of(first, rest);
        }
     
    -   Quantifier() {
    -           this.properties = EnumSet.noneOf(QuantifierProperty.class);
    +   public static Quantifier ONE() {
    +           return new Quantifier(QuantifierProperty.SINGLE);
    +   }
    +
    +   public static Quantifier ONE_OR_MORE() {
    +           return new Quantifier(QuantifierProperty.LOOPING, 
QuantifierProperty.EAGER);
    +   }
    +
    +   public static Quantifier TIMES() {
    +           return new Quantifier(QuantifierProperty.TIMES, 
QuantifierProperty.EAGER);
        }
     
        public boolean hasProperty(QuantifierProperty property) {
                return properties.contains(property);
        }
     
    +   public void combinations() {
    +           if (!hasProperty(Quantifier.QuantifierProperty.EAGER)) {
    +                   throw new MalformedPatternException("Combinations 
already allowed!");
    +           }
    +
    +           if (hasProperty(Quantifier.QuantifierProperty.LOOPING) || 
hasProperty(Quantifier.QuantifierProperty.TIMES)) {
    +                   properties.remove(Quantifier.QuantifierProperty.EAGER);
    +           } else {
    +                   throw new MalformedPatternException("Combinations not 
applicable to " + this + "!");
    +           }
    +   }
    +
    +   public void consecutive() {
    +           if (hasProperty(Quantifier.QuantifierProperty.CONSECUTIVE)) {
    --- End diff --
    
    Same here for the `ONE` quantifier.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to