Skip to content
3 changes: 3 additions & 0 deletions docs/reference/method-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,19 @@ The below table shows some more examples of method patterns and the methods they
| `java.lang.String substring(int, int)` | Exactly the [two argument overload](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#substring%28int,int%29) of `String.substring(int beginIndex, int endIndex)`. |
| `java.lang.String substring(..)` | Any overload of `String.substring()` with any number of arguments. |
| `java.lang.String *(int)` | Any method on `String` that accepts a single argument of type `int`. |
| `java.lang.String valueOf(*)` | Any overload of `String.valueOf()` with exactly one argument. |
| `java.lang.String format(String, ..)` | Exactly the [String.format(String format, Object... args)](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#format\(java.lang.String,java.lang.Object...\)) method with varargs. |
| `java.lang.String format(String, Object[])` | Exactly the [String.format(String format, Object... args)](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#format\(java.lang.String,java.lang.Object...\)) method with varargs. |
| `com.yourorg.Foo bar(int, String, ..)` | Any method on `Foo` named `bar` accepting an `int`, a `String`, and zero or more other arguments of any type. |
| `*..String *(..)` | Any method accepting any arguments on classes named "String" in any package. |
| `*..* *(..)` | Any method accepting any arguments on any class. |
| `*..* *(*, *, *, ..)` | Any method accepting at least three arguments on any class. |
| `*..* foo(..)` | Any method named `foo` which accepts any number of arguments. This is the equivalent of doing a generic text search for methods named `foo`. |
| `org..* foo(..)` | Any method named `foo` in a package that starts with `org`. This could be `org.meow` or it could be `org.springframework` or so on. |
| `org.openrewrite.java.* foo(..)` | Any method named `foo` in a package that starts with `org.openrewrite.java.`. Note that the `.*` after `java` means that the method _must_ be in this package rather than some subsequent subpackages. |
| `org.Foo bar(java.util.List)` | Exactly the `bar` method in the `org.Foo` class that takes in a single `java.util.List` as an argument. |
Comment thread
jevanlingen marked this conversation as resolved.
| `org.Foo <constructor>(..)` | Matches any constructors in the `org.Foo` class that takes in any number of arguments. |
| `org.Foo <init>(..)` | Matches any constructors in the `org.Foo` class that takes in any number of arguments. |
Comment thread
jevanlingen marked this conversation as resolved.
Outdated
| `org.Foo bar()` | Matches exactly the `bar` method in the `org.Foo` class that has **no** arguments |
| `org.Foo#bar()` | Matches the same thing as the previous line. Demonstrates that `#` can be used to replace a space – which may be useful for certain types of input such as a CLI. |

Expand Down
Loading