Interface MethodMatchers

All Known Implementing Classes:
MethodMatchersBuilder, MethodMatchersList, NoneMethodMatchers

@Beta public interface MethodMatchers
Immutable helper interface to help to identify method with given a Type, Name and Parameters.

The starting point to define a MethodMatchers is create().

It is required to provide the following:

The matcher will return true only when the three predicates are respected.

Examples:

  • 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(
          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();