Class MethodMatcher
#declaring class# #method name#(#argument list#)
EXAMPLES:*..* *(..) - All method invocations java.util.* *(..) - All method invocations to classes belonging to java.util (including sub-packages) java.util.Collections *(..) - All method invocations on java.util.Collections class java.util.Collections unmodifiable*(..) - All method invocations starting with "unmodifiable" on java.util.Collections java.util.Collections min(..) - All method invocations for all overloads of "min" java.util.Collections emptyList() - All method invocations on java.util.Collections.emptyList() my.org.MyClass *(boolean, ..) - All method invocations where the first arg is a boolean in my.org.MyClass
-
Constructor Summary
ConstructorsConstructorDescriptionMethodMatcher
(String signature) MethodMatcher
(String signature, boolean matchOverrides) MethodMatcher
(String signature, @Nullable Boolean matchOverrides) MethodMatcher
(org.openrewrite.java.tree.J.MethodDeclaration method) MethodMatcher
(org.openrewrite.java.tree.J.MethodDeclaration method, boolean matchOverrides) MethodMatcher
(JavaType.Method method) -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Deprecated.Deprecated.boolean
isFullyQualifiedClassReference
(org.openrewrite.java.tree.J.FieldAccess fieldAccess) Evaluate whether this MethodMatcher and the specified FieldAccess are describing the same type or not.boolean
matches
(@Nullable Expression maybeMethod) boolean
matches
(@Nullable MethodCall methodCall) boolean
matches
(org.openrewrite.java.tree.J.MethodDeclaration method, org.openrewrite.java.tree.J.ClassDeclaration enclosing) boolean
matches
(org.openrewrite.java.tree.J.MethodInvocation method, boolean matchUnknownTypes) Prefermatches(MethodCall)
, which uses the default `false` behavior for matchUnknownTypes.boolean
matches
(JavaType.Method type) static String
methodPattern
(org.openrewrite.java.tree.J.MethodDeclaration method) static String
methodPattern
(JavaType.Method method) toString()
-
Constructor Details
-
MethodMatcher
-
MethodMatcher
-
MethodMatcher
public MethodMatcher(org.openrewrite.java.tree.J.MethodDeclaration method, boolean matchOverrides) -
MethodMatcher
-
MethodMatcher
public MethodMatcher(org.openrewrite.java.tree.J.MethodDeclaration method) -
MethodMatcher
-
-
Method Details
-
getTargetTypePattern
Deprecated. -
getMethodNamePattern
Deprecated. -
getArgumentPattern
Deprecated. -
matches
-
matches
-
matches
-
matches
public boolean matches(org.openrewrite.java.tree.J.MethodDeclaration method, org.openrewrite.java.tree.J.ClassDeclaration enclosing) -
matches
public boolean matches(@Nullable org.openrewrite.java.tree.J.MethodInvocation method, boolean matchUnknownTypes) Prefermatches(MethodCall)
, which uses the default `false` behavior for matchUnknownTypes. Using matchUnknownTypes can improve Visitor resiliency for an AST with missing type information, but also increases the risk of false-positive matches on unrelated MethodInvocation instances. -
isFullyQualifiedClassReference
public boolean isFullyQualifiedClassReference(org.openrewrite.java.tree.J.FieldAccess fieldAccess) Evaluate whether this MethodMatcher and the specified FieldAccess are describing the same type or not. Known limitation/bug: MethodMatchers can have patterns/wildcards like "com.*.Bar" instead of something concrete like "com.foo.Bar". This limitation is not desirable or intentional and should be fixed. If a methodMatcher is passed that includes wildcards the result will always be "false"- Parameters:
fieldAccess
- A J.FieldAccess that hopefully has the same fully qualified type as this matcher.
-
methodPattern
-
methodPattern
-
toString
-