private Matcher meta()

in spectator-api/src/main/java/com/netflix/spectator/impl/matcher/Parser.java [328:355]


  private Matcher meta(Matcher matcher) {
    int start = current - 1;
    advance(c -> META.contains((char) c));
    --current;
    String quantifier = tokens.subSequence(start, current).toString();
    switch (quantifier) {
      case "?":
        // Makes repeat reluctant
        if (matcher instanceof RepeatMatcher) {
          return matcher;
        }
      case "??":
      case "?+":
        return new ZeroOrOneMatcher(matcher, term());
      case "*":
      case "*?":
        return new ZeroOrMoreMatcher(matcher, term());
      case "*+":
        return new RepeatMatcher(matcher, 0, Integer.MAX_VALUE);
      case "+":
      case "+?":
        return SeqMatcher.create(matcher, new ZeroOrMoreMatcher(matcher, term()));
      case "++":
        return SeqMatcher.create(matcher, new RepeatMatcher(matcher, 1, Integer.MAX_VALUE));
      default:
        throw new IllegalArgumentException("unknown quantifier: " + quantifier);
    }
  }