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