1
2
3
4
5 package com.google.checkstyle.test.chapter4formatting.rule413emptyblocks;
6
7 import java.io.*;
8 import java.awt.Dimension;
9 import java.awt.Color;
10
11 class InputEmptyBlockBasic
12 {
13 static {}
14
15 public void fooMethod()
16 {
17 InputEmptyBlockBasic r = new InputEmptyBlockBasic();
18 int a = 1;
19 if (a == 1) {}
20 char[] s = {'1', '2'};
21 int index = 2;
22 if (doSideEffect() == 1) {}
23 IO in = new IO();
24 while ((r = in.read()) != null) {}
25 for (; index < s.length && s[index] != 'x'; index++) {}
26 if (a == 1) {} else {System.identityHashCode("a");}
27 do {} while(a == 1);
28 switch (a) {}
29 int[] z = {};
30 }
31
32 public int doSideEffect()
33 {
34 return 1;
35 }
36
37 public void emptyMethod() {}
38 }
39
40 class IO
41 {
42 public InputEmptyBlockBasic read()
43 {
44 return new InputEmptyBlockBasic();
45 }
46 }
47 class Empty {}
48
49 interface EmptyImplement {}
50
51 class WithInner
52 {
53 static {}
54
55 public void emptyMethod() {}
56
57 public int doSideEffect()
58 {
59 return 1;
60 }
61
62 class Inner
63 {
64 private void withEmpty()
65 {
66 InputEmptyBlockBasic r = new InputEmptyBlockBasic();
67 int a = 1;
68 if (a == 1) {}
69 char[] s = {'1', '2'};
70 int index = 2;
71 if (doSideEffect() == 1) {}
72 IO in = new IO();
73 while ((r = in.read()) != null) {}
74 for (; index < s.length && s[index] != 'x'; index++) {}
75 if (a == 1) {} else {System.identityHashCode("a");}
76 do {} while(a == 1);
77 switch (a) {}
78 int[] z = {};
79 }
80 }
81 }
82
83 class WithAnon
84 {
85 interface AnonWithEmpty {
86 public void fooEmpty();
87 }
88
89 void method()
90 {
91 AnonWithEmpty foo = new AnonWithEmpty() {
92
93 public void emptyMethod() {}
94
95 public void fooEmpty() {
96 InputEmptyBlockBasic r = new InputEmptyBlockBasic();
97 int a = 1;
98 if (a == 1) {}
99 char[] s = {'1', '2'};
100 int index = 2;
101 if (doSideEffect() == 1) {}
102 IO in = new IO();
103 while ((r = in.read()) != null) {}
104 for (; index < s.length && s[index] != 'x'; index++) {}
105 if (a == 1) {} else {System.identityHashCode("a");}
106 do {} while(a == 1);
107 switch (a) {}
108 int[] z = {};
109 }
110
111 public int doSideEffect()
112 {
113 return 1;
114 }
115 };
116 }
117 }
118
119 class NewClass {
120
121 void foo() {
122 int a = 1;
123
124 if (a == 1) {
125 System.identityHashCode("a");
126 } else {}
127
128 if (a == 1) {
129 System.identityHashCode("a");
130 } else {}
131
132 if (a == 1) {
133
134 } else {
135 System.identityHashCode("a");
136 }
137
138 if (a == 1) {
139 System.identityHashCode("a");
140 } else if (a != 1) {
141
142 } else {
143
144 }
145
146 if (a == 1) {
147
148 } else if (a != 1) {
149 System.identityHashCode("a");
150 } else {
151
152 }
153
154 if (a == 1) {
155
156 } else if (a != 1) {
157
158 } else {
159 System.identityHashCode("a");
160 }
161
162 if (a == 1) {
163
164 } else if (a != 1) {
165
166 } else {
167
168 }
169
170 if (a == 1) {
171
172 } else if (a != 1) {}
173 else {}
174
175 if (a == 1) {}
176 else if (a != 1) {
177
178 }
179 else {}
180
181 if (a == 1) {}
182 else if (a != 1) {}
183 else {
184
185 }
186 }
187
188 class NewInner {
189
190 void foo() {
191 int a = 1;
192
193 if (a == 1) {
194 System.identityHashCode("a");
195 } else {}
196
197 if (a == 1) {
198 System.identityHashCode("a");
199 } else {}
200
201 if (a == 1) {
202
203 } else {
204 System.identityHashCode("a");
205 }
206
207 if (a == 1) {
208 System.identityHashCode("a");
209 } else if (a != 1) {
210
211 } else {
212
213 }
214
215 if (a == 1) {
216
217 } else if (a != 1) {
218 System.identityHashCode("a");
219 } else {
220
221 }
222
223 if (a == 1) {
224
225 } else if (a != 1) {
226
227 } else {
228 System.identityHashCode("a");
229 }
230
231 if (a == 1) {
232
233 } else if (a != 1) {
234
235 } else {
236
237 }
238
239 if (a == 1) {
240
241 } else if (a != 1) {}
242 else {}
243
244 if (a == 1) {}
245 else if (a != 1) {
246
247 }
248 else {}
249
250 if (a == 1) {}
251 else if (a != 1) {}
252 else {
253
254 }
255 }
256
257 NewInner anon = new NewInner() {
258
259 void foo() {
260 int a = 1;
261
262 if (a == 1) {
263 System.identityHashCode("a");
264 } else {}
265
266 if (a == 1) {
267 System.identityHashCode("a");
268 } else {}
269
270 if (a == 1) {
271
272 } else {
273 System.identityHashCode("a");
274 }
275
276 if (a == 1) {
277 System.identityHashCode("a");
278 } else if (a != 1) {
279
280 } else {
281
282 }
283
284 if (a == 1) {
285
286 } else if (a != 1) {
287 System.identityHashCode("a");
288 } else {
289
290 }
291
292 if (a == 1) {
293
294 } else if (a != 1) {
295
296 } else {
297 System.identityHashCode("a");
298 }
299
300 if (a == 1) {
301
302 } else if (a != 1) {
303
304 } else {
305
306 }
307
308 if (a == 1) {
309
310 } else if (a != 1) {}
311 else {}
312
313 if (a == 1) {}
314 else if (a != 1) {
315
316 }
317 else {}
318
319 if (a == 1) {}
320 else if (a != 1) {}
321 else {
322
323 }
324 }
325 };
326 }
327 }
328
329 class Example {
330
331 void doNothing() {}
332
333 void doNothingElse() {
334
335 }
336 }