Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor docs update for java-frontend/src/main/java/org/sonar/plugins/java/api/semantic/MethodMatchers.java #4817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
* <li> {@link TypeBuilder#ofSubTypes(String...)} </li>
* <li> {@link TypeBuilder#ofTypes(String...)} </li>
* <li> {@link TypeBuilder#ofType(Predicate<Type>)} </li>
* <li> {@link TypeBuilder#ofAnyType()} // same as ofType(type -> true) </li>
* <li> {@link TypeBuilder#ofAnyType()} {@code // same as ofType(type -> true)} </li>
* </ul>
* </li>
* <li> a method name
* <ul>
* <li> {@link NameBuilder#names(String...)} </li>
* <li> {@link NameBuilder#constructor()} </li>
* <li> {@link NameBuilder#name(Predicate<String>)} </li>
* <li> {@link NameBuilder#anyName()} // same as name(name -> true) </li>
* <li> {@link NameBuilder#anyName()} {@code // same as name(name -> true)} </li>
* </ul>
* </li>
* <li>a list of parameters, 1 or more call to:
Expand All @@ -61,34 +61,46 @@
* <li> {@link ParametersBuilder#addWithoutParametersMatcher()} </li>
* <li> {@link ParametersBuilder#addParametersMatcher(String...)} </li>
* <li> {@link ParametersBuilder#addParametersMatcher(Predicate<List<Type>>)} </li>
* <li> {@link ParametersBuilder#withAnyParameters()} // same as addParametersMatcher((List<Type> parameters) -> true) </li>
* <li> {@link ParametersBuilder#withAnyParameters()} {@code // same as addParametersMatcher((List<Type> parameters) -> true)} </li>
* </ul>
* </li>
* </ul>
* The matcher will return true only when the three predicates are respected.
* <p>
* Examples:
* <pre>
*- match method "a" and "b" from any type, and without parameters:
* MethodMatchers.create().ofAnyType().names("a", "b").addWithoutParametersMatcher().build();
*
*- match method "a" and "b" from (subtype) of A, and "b" and "c" from B, with any parameters:
* MethodMatchers.or(
* <p>
* <ul>
* <li>match method "a" and "b" from any type, and without parameters:
* {@code MethodMatchers.create().ofAnyType().names("a", "b").addWithoutParametersMatcher().build();}
* </li>
* <li>match method "a" and "b" from (subtype) of A, and "b" and "c" from B, with any parameters:
* <pre>
* MethodMatchers.or(
* MethodMatchers.create().ofSubTypes("A").names("a", "b").withAnyParameters().build(),
* MethodMatchers.create().ofSubTypes("B").names("b", "c").withAnyParameters().build());
*- match method "f" with any type and with:
* MethodMatchers.create().ofAnyType().names("f")
* - one parameter of type either int or long
* .addParametersMatcher("int").addParametersMatcher("long");
* - one parameter of type int or one parameter of type long with any other number of parameters
* .addParametersMatcher("int").addParametersMatcher(params -> params.size() >= 1 && params.get(0).is("long"));
* .build()
*- match any method with any type, with parameter int, any, int:
* MethodMatchers.create().ofAnyType().anyName().addParametersMatcher("int", ANY, "int").build();
*
*- match any type AND method name "a" OR "b" AND parameter int OR long:
* MethodMatchers.create().ofAnyType().names("a", "b").addParametersMatcher("int").addParametersMatcher("long").build()
* </pre>
* </pre>
* </li>
* <li>
* match method "f" with any type and with:
* {@code MethodMatchers.create().ofAnyType().names("f")}
* <ul>
* <li>one parameter of type either {@code int} or {@code long}
* {@code .addParametersMatcher("int").addParametersMatcher("long");}
* </li>
* <li>
* one parameter of type {@code int} or one parameter of type {@code long} with any other number of parameters
* {@code .addParametersMatcher("int").addParametersMatcher(params -> params.size() >= 1 &amp;&amp; params.get(0).is("long"));}
* </li>
* </ul>
* {@code .build();}
* </li>
* <li>match any method with any type, with parameter {@code int, any, int}:
* {@code MethodMatchers.create().ofAnyType().anyName().addParametersMatcher("int", ANY, "int").build();}
* </li>
* <li>match any type AND method name {@code a} OR {@code b} AND parameter {@code int} OR {@code long}:
* {@code MethodMatchers.create().ofAnyType().names("a", "b").addParametersMatcher("int").addParametersMatcher("long").build();}
* </li>
* </ul>
*/
@Beta
public interface MethodMatchers {
Expand Down
Loading