View Javadoc
1   /*
2   OneStatementPerLine
3   treatTryResourcesAsStatement = (default)false
4   
5   
6   */
7   
8   package com.puppycrawl.tools.checkstyle.checks.coding.onestatementperline;
9   
10  public class InputOneStatementPerLineSingleLineForDeclarations {
11      /**
12       * Dummy variable to work on.
13       */
14      private int one = 0;
15  
16      /**
17       * Dummy variable to work on.
18       */
19      private int two = 0;
20      /**
21       * This method contains break, while-loop
22       * and for-loop statements.
23       */
24      private void foo3() {
25          do {
26              one++;
27              if (two > 4) {
28                  break; //legal
29              }
30              one++;
31              two++;
32          } while (two < 7); //legal
33  
34          /**
35           *  One statement inside for block is legal.
36           */
37          for (int i = 0; i < 10; i++) one = 5;
38  
39          /**
40           *  One statement inside for block where
41           *  increment expression is empty is legal.
42           */
43          for (int i = 0; i < 10;) one = 5;
44  
45          /**
46           *  One statement inside for block where
47           *  increment and conditional expressions are empty
48           *  (forever loop) is legal
49           */
50          for (int i = 0;;) one = 5;
51      }
52  
53      public void foo4() {
54          /**
55           * a "forever" loop.
56           */
57          for(;;){} //legal
58      }
59  
60      public void foo5() {
61          /**
62           *  One statement inside for block is legal
63           */
64          for (;;) { one = 5; }
65      }
66  
67      public void foo6() {
68          bar(() -> {
69              return;}, () -> {return;});
70      }
71  
72      void bar(Runnable r1, Runnable r2) { }
73  }