View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule42blockindentation;
2   
3   class InputIndentationCorrectWhileDoWhileAndParameter {
4   
5     String getString(int someInt, String someString) {
6       return "String";
7     }
8   
9     void fooMethodWithIf() {
10  
11      while (conditionFirst(
12          "Loooooooooooooooooong",
13          new SecondWhileLongNam1("Loooooooooooooooooog")
14              .getInteger(new FooWhileClass(), "Loooooooooooooooooog"),
15          new InnerClassFoo())) {}
16  
17      do {} while (conditionFirst(
18          "Loooooooooooooooooong",
19          new SecondWhileLongNam1("Loooooooooooooooooog")
20              .getInteger(new FooWhileClass(), "Loooooooooooooooooog"),
21          new InnerClassFoo()));
22  
23      while (conditionSecond(
24              10000000000.0,
25              new SecondWhileLongNam1("Looooooooooooo" + "oooooooooooong")
26                  .getString(
27                      new FooWhileClass(),
28                      new SecondWhileLongNam1("loooooooooong")
29                          .getInteger(new FooWhileClass(), "loooooooooooooong")),
30              "loooooooooooong")
31          || conditionThird(2048)
32          || conditionFourth(
33              new SecondWhileLongNam1("Looooooooooooooo" + "ooooooooooooong")
34                  .getBoolean(new FooWhileClass(), false))
35          || conditionFifth(
36              true,
37              new SecondWhileLongNam1(
38                      getString(2048, "Looo" + "ooooooooooooooooooooooooooooooooooooooooooong"))
39                  .getBoolean(new FooWhileClass(), true))
40          || conditionSixth(
41              false, new SecondWhileLongNam1(getString(100000, "Loooooong" + "Fooooooo><")))
42          || conditionNoArg()
43          || conditionNoArg()
44          || conditionNoArg()
45          || conditionNoArg()) {}
46  
47      do {} while (conditionSecond(
48              10000000000.0,
49              new SecondWhileLongNam1("Looooooooooooo" + "oooooooooooong")
50                  .getString(
51                      new FooWhileClass(),
52                      new SecondWhileLongNam1("loooooooooong")
53                          .getInteger(new FooWhileClass(), "loooooooong")),
54              "loooooooooooong")
55          || conditionThird(2048)
56          || conditionFourth(
57              new SecondWhileLongNam1("Looooooooooooooo" + "ooooooooooooong")
58                  .getBoolean(new FooWhileClass(), false))
59          || conditionFifth(
60              true,
61              new SecondWhileLongNam1(
62                      getString(2048, "Looo" + "ooooooooooooooooooooooooooooooooooooooooooong"))
63                  .getBoolean(new FooWhileClass(), true))
64          || conditionSixth(
65              false, new SecondWhileLongNam1(getString(100000, "Loooooong" + "Fooooooo><")))
66          || conditionNoArg()
67          || conditionNoArg()
68          || conditionNoArg()
69          || conditionNoArg());
70    }
71  
72    private boolean conditionFirst(String longString, int integer, InnerClassFoo someInstance) {
73      return false;
74    }
75  
76    private boolean conditionSecond(
77        double longLongLongDoubleValue, String longLongLongString, String secondLongLongString) {
78      return false;
79    }
80  
81    private boolean conditionThird(long veryLongValue) {
82      return false;
83    }
84  
85    private boolean conditionFourth(boolean flag) {
86      return false;
87    }
88  
89    private boolean conditionFifth(boolean flag1, boolean flag2) {
90      return false;
91    }
92  
93    private boolean conditionSixth(boolean flag, SecondWhileLongNam1 instance) {
94      return false;
95    }
96  
97    private boolean conditionNoArg() {
98      return false;
99    }
100 
101   class InnerClassFoo {
102 
103     FooWhileClass anonymousClass =
104         new FooWhileClass() {
105 
106           void fooMethodWithIf(
107               String stringStringStringStringLooooongString,
108               int intIntIntVeryLongNameForIntVariable,
109               boolean fooooooooobooleanBooleanVeryLongName) {
110 
111             while (conditionFirst(
112                 "Loooooooooooooooooong",
113                 new SecondWhileLongNam1("Loooooooooooooooooog")
114                     .getInteger(new FooWhileClass(), "Loooooooooooooooooog"),
115                 new InnerClassFoo())) {}
116 
117             do {
118               /* Do smth*/
119 
120             } while (conditionFirst(
121                 "Loooooooooooooooooong",
122                 new SecondWhileLongNam1("Loooooooooooooooooog")
123                     .getInteger(new FooWhileClass(), "Loooooooooooooooooog"),
124                 new InnerClassFoo()));
125 
126             while (conditionSecond(
127                     10000000000.0,
128                     new SecondWhileLongNam1("Looooooooooooo" + "oooooooooooong")
129                         .getString(
130                             new FooWhileClass(),
131                             new SecondWhileLongNam1("loooooooooong")
132                                 .getInteger(new FooWhileClass(), "loooooooooong")),
133                     "loooooooooooong")
134                 || conditionThird(2048)
135                 || conditionFourth(
136                     new SecondWhileLongNam1("Looooooooooooooo" + "ooooooooooooong")
137                         .getBoolean(new FooWhileClass(), false))
138                 || conditionFifth(
139                     true,
140                     new SecondWhileLongNam1(
141                             getString(2048, "Lo" + "ooooooooooooooooooooooooooooooooooooooooooong"))
142                         .getBoolean(new FooWhileClass(), true))
143                 || conditionSixth(
144                     false, new SecondWhileLongNam1(getString(100000, "Loooooong" + "Fooooooo><")))
145                 || conditionNoArg()
146                 || conditionNoArg()
147                 || conditionNoArg()
148                 || conditionNoArg() && fooooooooobooleanBooleanVeryLongName) {}
149 
150             do {
151               /* Do smth*/
152 
153             } while (conditionSecond(
154                     10000000000.0,
155                     new SecondWhileLongNam1("Looooooooooooo" + "oooooooooooong")
156                         .getString(
157                             new FooWhileClass(),
158                             new SecondWhileLongNam1("loooooooooong")
159                                 .getInteger(new FooWhileClass(), "loooooooooong")),
160                     "loooooooooooong")
161                 || conditionThird(2048)
162                 || conditionFourth(
163                     new SecondWhileLongNam1("Looooooooooooooo" + "ooooooooooooong")
164                         .getBoolean(new FooWhileClass(), false))
165                 || conditionFifth(
166                     true,
167                     new SecondWhileLongNam1(
168                             getString(2048, "Lo" + "ooooooooooooooooooooooooooooooooooooooooooong"))
169                         .getBoolean(new FooWhileClass(), true))
170                 || conditionSixth(
171                     false, new SecondWhileLongNam1(getString(100000, "Loooooong" + "Fooooooo><")))
172                 || conditionNoArg()
173                 || conditionNoArg()
174                 || conditionNoArg()
175                 || conditionNoArg() && fooooooooobooleanBooleanVeryLongName);
176           }
177         };
178 
179     void fooMethodWithIf() {
180       while (conditionFirst(
181           "Loooooooooooooooooong",
182           new SecondWhileLongNam1("Loooooooooooooooooog")
183               .getInteger(new FooWhileClass(), "Loooooooooooooooooog"),
184           new InnerClassFoo())) {}
185 
186       do {
187         /* Do something*/
188 
189       } while (conditionFirst(
190           "Loooooooooooooooooong",
191           new SecondWhileLongNam1("Loooooooooooooooooog")
192               .getInteger(new FooWhileClass(), "Loooooooooooooooooog"),
193           new InnerClassFoo()));
194 
195       while (conditionSecond(
196               10000000000.0,
197               new SecondWhileLongNam1("Looooooooooooo" + "oooooooooooong")
198                   .getString(
199                       new FooWhileClass(),
200                       new SecondWhileLongNam1("loooooooooong")
201                           .getInteger(new FooWhileClass(), "loooooooooooong")),
202               "loooooooooooong")
203           || conditionThird(2048)
204           || conditionFourth(
205               new SecondWhileLongNam1("Looooooooooooooo" + "ooooooooooooong")
206                   .getBoolean(new FooWhileClass(), false))
207           || conditionFifth(
208               true,
209               new SecondWhileLongNam1(
210                       getString(2048, "Looo" + "ooooooooooooooooooooooooooooooooooooooooooong"))
211                   .getBoolean(new FooWhileClass(), true))
212           || conditionSixth(
213               false, new SecondWhileLongNam1(getString(100000, "Loooooong" + "Fooooooo><")))
214           || conditionNoArg()
215           || conditionNoArg()
216           || conditionNoArg()
217           || conditionNoArg()) {}
218 
219       do {
220         /* Do smth*/
221 
222       } while (conditionSecond(
223               10000000000.0,
224               new SecondWhileLongNam1("Looooooooooooo" + "oooooooooooong")
225                   .getString(
226                       new FooWhileClass(),
227                       new SecondWhileLongNam1("loooooooooong")
228                           .getInteger(new FooWhileClass(), "loooooooooooong")),
229               "loooooooooooong")
230           || conditionThird(2048)
231           || conditionFourth(
232               new SecondWhileLongNam1("Looooooooooooooo" + "ooooooooooooong")
233                   .getBoolean(new FooWhileClass(), false))
234           || conditionFifth(
235               true,
236               new SecondWhileLongNam1(
237                       getString(2048, "Looo" + "ooooooooooooooooooooooooooooooooooooooooooong"))
238                   .getBoolean(new FooWhileClass(), true))
239           || conditionSixth(
240               false, new SecondWhileLongNam1(getString(100000, "Loooooong" + "Fooooooo><")))
241           || conditionNoArg()
242           || conditionNoArg()
243           || conditionNoArg()
244           || conditionNoArg());
245     }
246   }
247 
248   class SecondWhileLongNam1 {
249 
250     public SecondWhileLongNam1(String string) {}
251 
252     String getString(FooWhileClass instance, int integer) {
253       return "String";
254     }
255 
256     int getInteger(FooWhileClass instance, String string) {
257       return -1;
258     }
259 
260     boolean getBoolean(FooWhileClass instance, boolean flag) {
261       return false;
262     }
263 
264     SecondWhileLongNam1 getInstance() {
265       return new SecondWhileLongNam1("VeryLoooooooooo" + "oongString");
266     }
267   }
268 
269   class FooWhileClass {}
270 }