View Javadoc
1   /*
2   MethodName
3   format = (default)^[a-z][a-zA-Z0-9]*$
4   allowClassName = (default)false
5   applyToPublic = (default)true
6   applyToProtected = (default)true
7   applyToPackage = (default)true
8   applyToPrivate = (default)true
9   
10  
11  */
12  
13  package com.puppycrawl.tools.checkstyle.checks.naming.methodname;
14  
15  /**
16   * Test input for MethodNameCheck specifically
17   * whether the method name equals the class name.
18   *
19   * @author Travis Schneeberger
20   */
21  public class InputMethodNameEqualClassName {
22  
23          //illegal name
24      public int InputMethodNameEqualClassName() { // 2 violations
25          return 0;
26      }
27  
28      //illegal name
29      private int PRIVATEInputMethodNameEqualClassName() { // violation
30          return 0;
31      }
32  
33      class Inner {
34                  //illegal name
35          public int Inner() { // 2 violations
36                          return 0;
37                  }
38  
39                  //OK name - name of the outter class's ctor
40          public int InputMethodNameEqualClassName() { // violation
41                          return 0;
42                  }
43          }
44  
45          public void anotherMethod() {
46                  new InputMethodNameEqualClassName() {
47  
48                          //illegal name
49              public int InputMethodNameEqualClassName() { // 2 violations
50                                  return 1;
51                          }
52                  };
53          }
54  }
55  
56  interface SweetInterface {
57  
58          //illegal name
59      int SweetInterface(); // 2 violations
60  }
61  
62  class Outer {
63  
64          //illegal name
65      public void Outer() { // 2 violations
66  
67          }
68  }