Class MethodMatcher
- All Implemented Interfaces:
InvocationMatcher
#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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.openrewrite.java.InvocationMatcher
InvocationMatcher.AdvancedInvocationMatcher -
Constructor Summary
ConstructorsConstructorDescriptionMethodMatcher(String signature) MethodMatcher(String signature, boolean matchOverrides) MethodMatcher(String signature, @Nullable Boolean matchOverrides) MethodMatcher(J.MethodDeclaration method) MethodMatcher(J.MethodDeclaration method, boolean matchOverrides) MethodMatcher(JavaType.Method method) -
Method Summary
Modifier and TypeMethodDescriptionbooleanisFullyQualifiedClassReference(J.FieldAccess fieldAccess) Evaluate whether this MethodMatcher and the specified FieldAccess are describing the same type or not.booleanmatches(@Nullable Expression maybeMethod) booleanmatches(J.MemberReference memberReference) booleanmatches(J.MethodDeclaration method, J.ClassDeclaration enclosing) booleanmatches(J.MethodInvocation method) booleanmatches(J.MethodInvocation method, boolean matchUnknownTypes) Prefermatches(J.MethodInvocation), which uses the default `false` behavior for matchUnknownTypes.booleanmatches(J.NewClass constructor) booleanmatches(JavaType.Method type) static StringmethodPattern(J.MethodDeclaration method) static StringmethodPattern(JavaType.Method method) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openrewrite.java.InvocationMatcher
advanced
-
Constructor Details
-
MethodMatcher
-
MethodMatcher
-
MethodMatcher
-
MethodMatcher
-
MethodMatcher
-
MethodMatcher
-
-
Method Details
-
matches
-
matches
-
matches
- Specified by:
matchesin interfaceInvocationMatcher
-
matches
-
matches
Prefermatches(J.MethodInvocation), 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. -
matches
-
matches
-
isFullyQualifiedClassReference
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
-