1 package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
2
3 class InputFormattedNonemptyBlocksLeftRightCurly {
4
5
6
7
8
9 boolean condition() {
10 return false;
11 }
12
13
14 void testDoWhile() {
15
16 do {
17 testDoWhile();
18 } while (condition());
19
20 do {
21 testDoWhile();
22 } while (condition());
23 }
24
25
26 void testWhile() {
27
28 while (condition()) {
29 testWhile();
30 }
31
32 while (condition()) {
33
34 }
35 while (condition()) {
36 testWhile();
37 }
38 while (condition()) {
39 if (condition()) {
40 testWhile();
41 }
42 }
43 }
44
45
46 void testFor() {
47
48 for (int i = 1; i < 5; i++) {
49 testFor();
50 }
51
52 for (int i = 1; i < 5; i++) {
53
54 }
55 for (int i = 1; i < 5; i++) {
56 testFor();
57 }
58 for (int i = 1; i < 5; i++) {
59 if (i > 2) {
60 testFor();
61 }
62 }
63 }
64
65
66 public void testIf() {
67
68 if (condition()) {
69 testIf();
70 } else if (condition()) {
71 testIf();
72 } else {
73 testIf();
74 }
75
76 if (condition()) {
77
78 }
79 if (condition()) {
80 testIf();
81 }
82 if (condition()) {
83 testIf();
84 } else {
85 testIf();
86 }
87 if (condition()) {
88 testIf();
89 } else {
90 testIf();
91 }
92 if (condition()) {
93 testIf();
94 } else {
95 testIf();
96 }
97 if (condition()) {
98 if (condition()) {
99 testIf();
100 }
101 }
102 }
103
104 void whitespaceAfterSemi() {
105
106 int i = 1;
107 int j = 2;
108
109 for (; ; ) {}
110 }
111
112
113 public InputFormattedNonemptyBlocksLeftRightCurly() {}
114
115
116 public void emptyImplementation() {}
117 }
118
119
120 class EnumContainerLeft2 {
121 private enum Suit {
122 CLUBS,
123 HEARTS,
124 SPADES,
125 DIAMONDS
126 }
127 }
128
129
130 class WithArraysLeft2 {
131 String[] s1 = {""};
132 String[] empty = {};
133 String[] s2 = {
134 "foo", "foo",
135 };
136 String[] s3 = {
137 "foo", "foo",
138 };
139 String[] s4 = {
140 "foo", "foo",
141 };
142 String[] s5 = {"foo", "foo"};
143 }
144
145
146 class InputRightCurlyOther22 {
147
148
149
150
151
152 int foo() throws InterruptedException {
153 int x = 1;
154 int a = 2;
155 while (true) {
156 try {
157 if (x > 0) {
158 break;
159 } else if (x < 0) {
160
161 ;
162 } else {
163 break;
164 }
165 switch (a) {
166 case 0:
167 break;
168 default:
169 break;
170 }
171 } catch (Exception e) {
172 break;
173 }
174 }
175
176 synchronized (this) {
177 do {
178 x = 2;
179 } while (x == 2);
180 }
181
182 this.wait(666);
183
184 for (int k = 0; k < 1; k++) {
185 String innerBlockVariable = "";
186 }
187
188 if (System.currentTimeMillis() > 1000) {
189 return 1;
190 } else {
191 return 2;
192 }
193 }
194
195 static {
196 int x = 1;
197 }
198
199
200 public enum GreetingsEnum {
201 HELLO,
202 GOODBYE
203 }
204
205 void method2() {
206 boolean flag = true;
207 if (flag) {
208 System.identityHashCode("heh");
209 flag = !flag;
210 }
211 System.identityHashCode("Xe-xe");
212
213 if (flag) {
214 System.identityHashCode("some foo");
215 }
216 }
217 }
218
219
220
221
222
223 class FooCtor2 {
224 int i3;
225
226 public FooCtor2() {
227 i3 = 1;
228 }
229 }
230
231
232
233 class FooMethod2 {
234 public void fooMethod() {
235 int i = 1;
236 }
237 }
238
239
240
241
242
243 class FooInner2 {
244 class InnerFoo {
245 public void fooInnerMethod() {}
246 }
247 }
248
249
250 class EnumContainer2 {
251 private enum Suit {
252 CLUBS,
253 HEARTS,
254 SPADES,
255 DIAMONDS
256 }
257 }
258
259
260 class WithArrays2 {
261 String[] test = {""};
262 String[] empty = {};
263 String[] s1 = {
264 "foo", "foo",
265 };
266 String[] s2 = {
267 "foo", "foo",
268 };
269 String[] s3 = {
270 "foo", "foo",
271 };
272 String[] s4 = {"foo", "foo"};
273 }