A pattern which matches <code>pattern1</code> followed by <code>pattern2</code>.
@param pattern1
@param pattern2
@return
779893
public static Pattern sequence(Pattern pattern1, Pattern pattern2)
   {
      if (pattern1 == null || pattern2 == null)
      {
         throw new IllegalArgumentException("Neither pattern can be null");
      }
      return new SequencePattern(pattern1, pattern2);
   }
1168107
private static boolean matchesPatternList(final String str, final List<Pattern> patterns) {
        if (patterns != null) {
            for (final Pattern pattern : patterns) {
                if (pattern.matcher(str).matches()) {
                    return true;
                }
            }
        }
        return false;
    }
1120015
public <B, C> DecomposableMatchBuilder2<T, B, C> decomposeFirst(
      DecomposableMatchBuilder2<A, B, C> first) {
    Objects.requireNonNull(first);

    Map<Integer, DecomposableMatchBuilder> buildersByIndex = Maps.treeMapOf(extractedIndex, first);

    List<Matcher<Object>> matchers = getChildMatchers(buildersByIndex);

    Tuple2<Integer, Integer> newIndexes = Tuple2.of(
        extractedIndex + first.extractedIndexes.first(),
        extractedIndex + first.extractedIndexes.second());

    NestedFieldExtractor<T> nestedFieldExtractor = getNestedFieldExtractor(buildersByIndex);

    return new DecomposableMatchBuilder2<>(matchers, newIndexes, nestedFieldExtractor);
  }
1240799
private static boolean doesNameMatchPattern(final Principal principal, final Pattern pattern) {
        if (pattern != null) {
            val name = principal.getName();
            val result = pattern.matcher(name).matches();
            LOGGER.debug("[{}] matches [{}] == [{}]", pattern.pattern(), name, result);
            return result;
        }
        return true;
    }
179757
private static boolean argsMatch(AbstractExpression e1, AbstractExpression e2) {
        final List<AbstractExpression> args1 = e1.getArgs(), args2 = e2.getArgs();
        if (args1 == null || args2 == null) {
            return args1 == args2;
        } else {
            return args1.size() == args2.size() &&
                    IntStream.range(0, args1.size())
                    .mapToObj(index -> (new FilterMatcher(args1.get(index), args2.get(index))).match())
                    .reduce(Boolean::logicalAnd).get();
        }
    }
609574
public <U extends T, A, B> InitialMatching2<T, U, A, B> when(
      DecomposableMatchBuilder2<U, A, B> decomposableMatchBuilder) {
    return new InitialMatching2<>(decomposableMatchBuilder.build(), value);
  }
1175474
private static boolean samePattern(String value1, String value2) {
        if (value1.length() == 0) {
            return value2.length() == 0;
        }
        if (value1.charAt(0) == '{') {
            return value2.length() > 0 && value2.charAt(0) == '{';
        }
        return value1.equals(value2);
    }
1329542
public static <A, B, EA extends A, EB extends B> DecomposableMatchBuilder0<Tuple2<A, B>> tuple2(
      DecomposableMatchBuilder0<EA> a, DecomposableMatchBuilder0<EB> b) {
    List<Matcher<Object>> matchers = Lists.of(ArgumentMatchers.any(), ArgumentMatchers.any());
    return new DecomposableMatchBuilder2<Tuple2<A, B>, EA, EB>(
        matchers, Tuple2.of(0, 1), new Tuple2FieldExtractor<>()).decomposeFirstAndSecond(a, b);
  }
1068214
public static Pattern and(final Pattern... patterns) {
    return new Pattern() {
      @Override public int match(CharSequence src, int begin, int end) {
        int ret = 0;
        for (Pattern pattern : patterns) {
          int l = pattern.match(src, begin, end);
          if (l == MISMATCH) return MISMATCH;
          if (l > ret) ret = l;
        }
        return ret;
      }

      @Override public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append('(');
        for (Pattern pattern : patterns) {
          sb.append(pattern).append(" & ");
        }
        if (sb.length() > 1) {
          sb.delete(sb.length() - 3, sb.length());
        }
        return sb.append(')').toString();
      }
    };
  }
55353
public static List<String> match(List<String> patterns, String name) {
        List<String> matches = new ArrayList<String>();
        for (String pattern : patterns) {
            if (match(pattern, name)) {
                matches.add(pattern);
            }
        }
        return matches;
    }
815085
public static @Nonnull Predicate nameContains(final @Nonnull Pattern pattern) {
        return new Predicate() {
            @Override
            public boolean isValid(@Nonnull ProcessThread<?, ?, ?> thread) {
                return pattern.matcher(thread.getName()).find();
            }
        };
    }
1168480
public static boolean isMatched(String pattern, String reg) {
        Pattern compile = Pattern.compile(reg);
        return compile.matcher(pattern).matches();
    }
1226023
protected boolean name_matches(String pattern) {
	pattern = pattern.toLowerCase().replaceAll("[*]{1}", ".*?");
	return name.toLowerCase().matches(pattern) || get_fully_qualified_name().toLowerCase().matches(pattern);
    }
972713
public static boolean match(WildcardPattern[] patterns, String value) {
    for (WildcardPattern pattern : patterns) {
      if (pattern.match(value)) {
        return true;
      }
    }
    return false;
  }
995272
public static final String convertPattern(String pattern) {
        if (pattern == null) {
            return null;
        }
        else {
            String convertedPattern = pattern;
            for (PatternConverter converter : PATTERN_CONVERTERS) {
                convertedPattern = converter.convert(convertedPattern);
            }

            return convertedPattern;
        }
    }
114632
public static <T extends Tree> Matcher<T> packageMatches(Pattern pattern) {
    return (tree, state) -> pattern.matcher(getPackageFullName(state)).matches();
  }
901396
public static Pattern compile(String pattern) throws IllegalArgumentException {
        if (pattern == null) {
            throw new IllegalArgumentException("Pattern can not be null");
        }

        if (pattern.startsWith("/") && pattern.endsWith("/") && pattern.length() > 1) {
            // This is a regular expression
            // So create matcher as is
            try {
                return Pattern.compile(pattern.substring(1, pattern.length() - 1));
            } catch (PatternSyntaxException e) {
                throw new IllegalArgumentException("Pattern contains an invalid expression", e);
            }
        }

        StringBuilder rEPattern = new StringBuilder("^");

        for (int i = 0; i < pattern.length(); i++) {
            if (pattern.charAt(i) == '*')
                rEPattern.append('.');
            if (pattern.charAt(i) == '?') {
                rEPattern.append('.');
            } else {
                rEPattern.append(pattern.charAt(i));
            }
        }

        rEPattern.append("$");

        try {
            return Pattern.compile(rEPattern.toString());
        } catch (PatternSyntaxException e) {
            throw new IllegalArgumentException("Pattern contains an invalid expression", e);
        }
    }