View Javadoc
1   /*
2   OneTopLevelClass
3   
4   
5   */
6   
7   package com.puppycrawl.tools.checkstyle.checks.design.onetoplevelclass;
8   
9   public class InputOneTopLevelClass
10  {
11      static final int FOO2 = 3;
12  
13      // violation: public before package
14      public static final int FOO = 3;
15  
16      private static final int FOO3 = 3;
17  
18      // violation: public before package and private
19      public static final int FOO4 = 3;
20  
21      private static final String ERROR = "error";
22  
23      // violation: protected before private
24      protected static final String ERROR1 = "error";
25  
26      // violation: public before private
27      public static final String WARNING = "warning";
28  
29      private int mMaxInitVars = 3;
30  
31      // violation: statics should be before instance members
32      // violation: publics before private
33      public static final int MAX_ITER_VARS = 3;
34  
35      private class InnerClass
36      {
37          private static final int INNER_FOO = 2;
38  
39          // violation: public before private
40          public static final int INNER_FOO2 = 2;
41  
42          public InnerClass()
43          {
44              int foo = INNER_FOO;
45              foo += INNER_FOO2;
46              foo += INNER_FOO3;
47          }
48  
49          // violation: member variables should be before methods or ctors
50          // violation: public before private
51          public static final int INNER_FOO3 = 2;
52      }
53  
54      public int getFoo1()
55      {
56          return mFoo;
57      }
58  
59      //  violation: ctors before methods
60      public InputOneTopLevelClass()
61      {
62          String foo = ERROR;
63          foo += ERROR1;
64          foo += WARNING;
65          int fooInt = mMaxInitVars;
66          fooInt += MAX_ITER_VARS;
67          fooInt += mFoo;
68      }
69  
70      public static int getFoo2()
71      {
72          return 13;
73      }
74  
75      public int getFoo()
76      {
77          return mFoo;
78      }
79  
80      private static int getFoo21()
81      {
82          return 14;
83      }
84  
85      // violation: member variables should be before methods or ctors
86      private int mFoo = 0;
87  }