method ====== .. include:: /ref/targets/autogen/descriptions/method.txt .. contents:: Configuration options --------------------- name ~~~~ Checks the name of the defined method. .. code-block:: yaml search: method: name: someMethod .. code-block:: java :emphasize-lines: 2-3 class Example { public void someMethod() { } } .. seealso:: The examples above use shorthands, see :doc:`string` target for more advanced configurations annotation ~~~~~~~~~~ Checks if the specified annotation is present. This option is configured using the :doc:`annotation` target. .. code-block:: yaml search: method: annotation: type: Deprecated .. code-block:: java :emphasize-lines: 2-4 class Example { @Deprecated public void someMethod() { } } type ~~~~ Checks the type of where this method has been declared. .. code-block:: yaml search: method: type: MyClass .. code-block:: java :emphasize-lines: 2-3 class MyClass { public void example() { } } .. seealso:: The examples above use shorthands, see :doc:`type` target for more advanced configurations child ~~~~~ Checks if this method contains a child that matches the target specification. .. code-block:: yaml search: method: child: methodcall: name: println .. code-block:: java :emphasize-lines: 2-4 class Example { public void example() { System.out.println("example"); } } returnType ~~~~~~~~~~ Checks the return type of the method. .. code-block:: yaml search: method: returnType: String .. code-block:: java :emphasize-lines: 2-3 class Example { public String example() { } } javadoc ~~~~~~~ Checks if the defined method contains a javadoc comment that matches the :doc:`javadoc` target. .. code-block:: yaml search: method: javadoc: contents: matches: ".*example.*" .. code-block:: java :emphasize-lines: 2-6 class Example { /** * this is an example. */ public String example() { } } modifier ~~~~~~~~ Checks if the method contains a modifier that matches the :doc:`string` target. All modifiers are matched separately. To match multiple modifiers, use ``allOf`` or ``anyOf``. .. code-block:: yaml search: method: modifier: "public" .. code-block:: java :emphasize-lines: 2-3 class Example { public String example() { } } example of multiple modifiers .. code-block:: yaml search: method: allOf: - modifier: "public" - modifier: "static" .. code-block:: java :emphasize-lines: 2-3 class Example { public static String example() { } } constructor ~~~~~~~~~~~ Checks if the defined method is a constructor. .. code-block:: yaml search: method: constructor: true .. code-block:: java :emphasize-lines: 2-3 class Example { public Example() { } public String example() { } } .. include:: /ref/targets/partials/searcher.txt