View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2011-2026 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.qulice.checkstyle;
6   
7   import com.puppycrawl.tools.checkstyle.api.DetailAST;
8   
9   /**
10   * Names of methods, tolerant to the methods of a JNA binding.
11   *
12   * <p>The stock {@code MethodName} check demands the same format from every
13   * method, while a method of a type that extends {@code com.sun.jna.Library}
14   * carries the name of a native function, spelled the way the library that
15   * exports it spells it. Renaming it breaks the binding, so the check stays
16   * silent there.</p>
17   *
18   * <p>Its messages come from the bundle of the stock check, since the two
19   * report the very same things and one wording for them is enough.</p>
20   *
21   * @since 1.0
22   */
23  public final class MethodNameCheck
24      extends com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck {
25  
26      /**
27       * Default constructor.
28       */
29      public MethodNameCheck() {
30          // nothing to initialize
31      }
32  
33      @Override
34      public void visitToken(final DetailAST ast) {
35          if (!new JnaBinding(ast).is()) {
36              super.visitToken(ast);
37          }
38      }
39  
40      @Override
41      public String getMessageBundle() {
42          return "com.puppycrawl.tools.checkstyle.checks.naming.messages";
43      }
44  }