KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > indentation > InputValidIfIndent


1 /*
2  * ValidIndent.java
3  *
4  * Created on November 6, 2002, 9:39 PM
5  */

6
7 package com.puppycrawl.tools.checkstyle.indentation;
8
9 /**
10  *
11  * @author jrichard
12  */

13 public class InputValidIfIndent {
14
15
16     // test ifs
17
public void emptyIfTest()
18     {
19         boolean test = true;
20
21         // lcurly on same line
22
if (test) {
23         }
24
25         // lcurly on next line
26
if (test)
27         {
28         }
29
30         // lcurly for if and else on same line
31
if (test) {
32         } else {
33         }
34
35         // lcurly for if and else on same line
36
if (test)
37         {
38         }
39         else
40         {
41         }
42
43         // lcurly for if and else on same line -- mixed braces
44
if (test) {
45         }
46         else
47         {
48         }
49
50
51         // lcurly for if and else on same line -- mixed braces
52
if (test)
53         {
54         } else
55         {
56         }
57
58         // lcurly for if and else on same line -- mixed braces
59
if (test)
60         {
61         } else {
62         }
63
64         // lcurly for if and else on same line -- mixed braces, unnested
65
if (test) {
66         }
67         else {
68         }
69
70         if (foo()
71             || test
72             || test)
73         {
74         }
75
76     }
77
78     ///// same as above, with statements
79
public void populatedIfTest()
80     {
81         boolean test = false;
82         // no braces if
83
if (test)
84             System.getProperty("blah");
85
86         // no braces if/else
87
if (test)
88             System.getProperty("blah");
89         else
90             System.getProperty("blah");
91
92
93         // lcurly on same line, and stmt
94
if (test) {
95             System.getProperty("blah");
96         }
97
98         // lcurly on next line and stmt
99
if (test)
100         {
101             System.getProperty("blah");
102         }
103         // lcurly for if and else on same line
104
if (test) {
105             System.getProperty("blah");
106         } else {
107             System.
108                 getProperty("blah");
109         }
110
111         // lcurly for if and else on same line
112
if (test)
113         {
114             System.getProperty("blah");
115             System.getProperty("blah");
116         }
117         else
118         {
119             System.getProperty("blah");
120         }
121
122         // lcurly for if and else on same line -- mixed braces
123
if (test) {
124             System.getProperty("blah");
125         }
126         else
127         {
128             System.getProperty("blah");
129         }
130
131
132         // lcurly for if and else on same line -- mixed braces
133
if (test)
134         {
135             System.getProperty("blah");
136         } else
137         {
138             System.getProperty("blah");
139         }
140
141         // lcurly for if and else on same line -- mixed braces
142
if (test)
143         {
144             System.getProperty("blah");
145         } else {
146             System.getProperty("blah");
147         }
148
149         // lcurly for if and else on same line -- mixed braces, unnested
150
if (test) {
151             System.getProperty("blah");
152         }
153         else {
154             System.getProperty("blah");
155         }
156
157         if (test) System.getProperty("blah");
158
159         if (test) System.getProperty("blah");
160         else System.getProperty("foo");
161
162         if (test) System.getProperty("blah");
163         else
164             System.getProperty("foo");
165
166         if (test)
167             System.getProperty("blah");
168         else System.getProperty("foo");
169
170         if (test
171             && 7 < 8 && 8 < 9
172             && 10 < 11) {
173         }
174
175         if (test)
176             return;
177
178
179         if (test) {
180         } else if (7 < 8) {
181         } else if (8 < 9) {
182         }
183
184         if (test) {
185             System.getProperty("blah");
186         } else if (7 < 8) {
187             System.getProperty("blah");
188         } else if (8 < 9) {
189             System.getProperty("blah");
190         }
191
192
193         if (test)
194             System.getProperty("blah");
195         else if (7 < 8)
196             System.getProperty("blah");
197         else if (8 < 9)
198             System.getProperty("blah");
199
200
201         // TODO: bother to support this style?
202
if (test) {
203             System.getProperty("blah");
204         } else
205             if (7 < 8) {
206                 System.getProperty("blah");
207             } else
208                 if (8 < 9) {
209                     System.getProperty("blah");
210                 }
211
212     }
213
214     public void parenIfTest() {
215         boolean test = true;
216
217         if (test
218         ) {
219             System.getProperty("blah");
220         }
221 //
222
if (test
223         )
224         {
225             System.getProperty("blah");
226         }
227
228         if
229         (
230             test
231         ) {
232             System.getProperty("blah");
233         }
234
235         if (test
236             )
237         {
238         }
239     }
240
241     boolean foo() {
242         return true;
243     }
244 }
245
Popular Tags