View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.indentation.indentation; //indent:0 exp:0
2   
3   /**                                                                           //indent:0 exp:0
4    * This test-input is intended to be checked using following configuration:   //indent:1 exp:1
5    *                                                                            //indent:1 exp:1
6    * arrayInitIndent = 4                                                        //indent:1 exp:1
7    * basicOffset = 4                                                            //indent:1 exp:1
8    * braceAdjustment = 0                                                        //indent:1 exp:1
9    * caseIndent = 4                                                             //indent:1 exp:1
10   * forceStrictCondition = false                                               //indent:1 exp:1
11   * lineWrappingIndentation = 4                                                //indent:1 exp:1
12   * tabWidth = 4                                                               //indent:1 exp:1
13   * throwsIndent = 4                                                           //indent:1 exp:1
14   *                                                                            //indent:1 exp:1
15   * @author  jrichard                                                         //indent:1 exp:1
16   */                                                                           //indent:1 exp:1
17  public class InputIndentationValidBlockIndent { //indent:0 exp:0
18  
19      /** Creates a new instance of InputValidBlockIndent */ //indent:4 exp:4
20      public InputIndentationValidBlockIndent() { //indent:4 exp:4
21      } //indent:4 exp:4
22  
23      public void method1() { //indent:4 exp:4
24  
25          { } //indent:8 exp:8
26          { //indent:8 exp:8
27          } //indent:8 exp:8
28          { //indent:8 exp:8
29              int var = 3; //indent:12 exp:12
30  
31              var += 3; //indent:12 exp:12
32          } //indent:8 exp:8
33  
34  
35          {  int var = 5; } //indent:8 exp:8
36  
37          { //indent:8 exp:8
38              int var = 3; //indent:12 exp:12
39  
40              var += 3; //indent:12 exp:12
41  
42              { //indent:12 exp:12
43                  int innerVar = 4; //indent:16 exp:16
44  
45                  innerVar += var; //indent:16 exp:16
46              } //indent:12 exp:12
47          } //indent:8 exp:8
48  
49      } //indent:4 exp:4
50  
51      static { int var = 4; } //indent:4 exp:4
52  
53  
54      static { //indent:4 exp:4
55          int var = 4;  //indent:8 exp:8
56      } //indent:4 exp:4
57  
58      static  //indent:4 exp:4
59      { //indent:4 exp:4
60          int var = 4;  //indent:8 exp:8
61      } //indent:4 exp:4
62  
63      { int var = 4; } //indent:4 exp:4
64  
65  
66      { //indent:4 exp:4
67          int var = 4;  //indent:8 exp:8
68      } //indent:4 exp:4
69  
70      { //indent:4 exp:4
71          int var = 4;  //indent:8 exp:8
72      } //indent:4 exp:4
73  
74  
75  } //indent:0 exp:0
76  
77  enum EquivalenceTester { //indent:0 exp:0
78      /** //indent:4 exp:4
79       * An equivalence tester that decides based on {@link Object#equals(Object) equals}. //indent:5 exp:5
80       */ //indent:5 exp:5
81      OBJECT_ATTRIBUTES { //indent:4 exp:4
82          /** //indent:8 exp:8
83           * {@inheritDoc} //indent:9 exp:9
84           */ //indent:9 exp:9
85          public boolean areEqual( final Object first, final Object second ) { //indent:8 exp:8
86              return true; //indent:12 exp:12
87          } //indent:8 exp:8
88  
89          /** //indent:8 exp:8
90           * {@inheritDoc} //indent:9 exp:9
91           */ //indent:9 exp:9
92          public int hashCode( final Object target ) { //indent:8 exp:8
93              return 1; //indent:12 exp:12
94          } //indent:8 exp:8
95      }, //indent:4 exp:4
96  
97      /** //indent:4 exp:4
98       * An equivalence tester that decides based on {@code ==}. //indent:5 exp:5
99       */ //indent:5 exp:5
100     OBJECT_IDENTITIES //indent:4 exp:4
101     { //indent:4 exp:4
102         /** //indent:8 exp:8
103          * {@inheritDoc} //indent:9 exp:9
104          */ //indent:9 exp:9
105         public boolean areEqual( final Object first, final Object second ) { //indent:8 exp:8
106             return first == second; //indent:12 exp:12
107         } //indent:8 exp:8
108 
109         /** //indent:8 exp:8
110          * {@inheritDoc} //indent:9 exp:9
111          */ //indent:9 exp:9
112         public int hashCode( final Object target ) { //indent:8 exp:8
113             return System.identityHashCode( target ); //indent:12 exp:12
114         } //indent:8 exp:8
115     }; //indent:4 exp:4
116 
117     /** //indent:4 exp:4
118      * Tells whether the two given objects are considered equivalent. //indent:5 exp:5
119      * //indent:5 exp:5
120      * @param first first comparand //indent:5 exp:5
121      * @param second second comparand //indent:5 exp:5
122      * @return whether {@code first} and {@code second} are considered equivalent //indent:5 exp:5
123      */ //indent:5 exp:5
124     public abstract boolean areEqual( Object first, Object second ); //indent:4 exp:4
125 
126     /** //indent:4 exp:4
127      * Computes a hash code for the given object. //indent:5 exp:5
128      * //indent:5 exp:5
129      * @param target object to compute a hash for //indent:5 exp:5
130      * @return the computed hash //indent:5 exp:5
131      */ //indent:5 exp:5
132     public abstract int hashCode( Object target ); //indent:4 exp:4
133 } //indent:0 exp:0
134 
135 class bug1251988 //indent:0 exp:0
136 { //indent:0 exp:0
137     private int a; //indent:4 exp:4
138 
139     // non static initializer //indent:4 exp:4
140     { //indent:4 exp:4
141         if (a == 1) //indent:8 exp:8
142         { //indent:8 exp:8
143         } //indent:8 exp:8
144     } //indent:4 exp:4
145 } //indent:0 exp:0
146 
147 class bug1260079 //indent:0 exp:0
148 { //indent:0 exp:0
149     public bug1260079() //indent:4 exp:4
150     { //indent:4 exp:4
151         new Thread() //indent:8 exp:8
152         { //indent:8 exp:8
153             public void run() //indent:12 exp:12
154             { //indent:12 exp:12
155                 System.identityHashCode("ran"); //indent:16 exp:16
156             } //indent:12 exp:12
157         }.start(); //indent:8 exp:8
158     } //indent:4 exp:4
159 } //indent:0 exp:0
160 
161 class bug1336737 { //indent:0 exp:0
162     private static enum Command { //indent:4 exp:4
163         IMPORT("import"), //indent:8 exp:8
164         LIST("list"); //indent:8 exp:8
165         private final String c; //indent:8 exp:8
166         Command(String c) { this.c = c; } //indent:8 exp:8
167         public String toString() { return c; } //indent:8 exp:8
168     } //indent:4 exp:4
169 } //indent:0 exp:0
170 
171 class AnonymousClassWithInitializer { //indent:0 exp:0
172     void create() { //indent:4 exp:4
173         new Object() { //indent:8 exp:8
174             { //indent:12 exp:12
175                 new Object(); //indent:16 exp:16
176             } //indent:12 exp:12
177         }; //indent:8 exp:8
178     } //indent:4 exp:4
179 } //indent:0 exp:0