Class MethodInvocationMatcher


public class MethodInvocationMatcher
extends Object
The machinery and type definitions necessary to model and compile a single efficient matcher out of a list of MethodMatchers.MethodMatchers.
  • Method Details

    • compiledAnyOf

      public static <T extends com.sun.source.tree.Tree> Matcher<T> compiledAnyOf​(Iterable<Matcher<? super T>> inputs)
      Compose several matchers together, such that the composite matches an AST node if any of the given matchers do.

      This is semantically equivalent to Matchers.anyOf(Iterable), but if the list of matchers contains more than one MethodMatchers.MethodMatcher, then anyMethod will do some work up front to try and optimize out the repeated work that those matchers would otherwise do. Consider profiling your matcher before using this method: the up-front work can be substantial, and if the list of matchers is small or the result of this method is not used often, the extra work may not pay for itself.

    • compile

      public static Matcher<com.sun.source.tree.ExpressionTree> compile​(Iterable<MethodInvocationMatcher.Rule> rules)
      Constructs a Matcher that matches for method invocations (including constructor invocations) satisfying at least one of the given Rule specifications. For an easy way to create such Rules, see the factories in Matchers returning subtypes of MethodMatchers.MethodMatcher.