View Javadoc
1   /*
2   OperatorWrap
3   option = EOL
4   tokens = (default)QUESTION, COLON, EQUAL, NOT_EQUAL, DIV, PLUS, MINUS, STAR, MOD, \
5            SR, BSR, GE, GT, SL, LE, LT, BXOR, BOR, LOR, BAND, LAND, TYPE_EXTENSION_AND, \
6            LITERAL_INSTANCEOF
7   
8   
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.whitespace.operatorwrap;
12  
13  import java.util.Arrays;
14  
15  /**
16   * Test case for detecting operator wrapping.
17   * @author Lars K�hne
18   **/
19  class InputOperatorWrap2
20  {
21      void test()
22      {
23          int x = 1 +
24              2 -
25              3
26              - // violation ''-' should be on the previous line.'
27              4;
28          x = x + 2;
29          boolean y = true
30              && // violation ''&&' should be on the previous line.'
31              false;
32          y = true &&
33              false;
34          y = false
35              && true; // violation ''&&' should be on the previous line.'
36          Arrays.sort(null, String
37                      ::
38                      compareToIgnoreCase);
39          Arrays.sort(null, String::
40                      compareToIgnoreCase);
41          Arrays.sort(null, String
42                      ::compareToIgnoreCase);
43      }
44  
45      void testAssignment()
46      {
47          int x
48              = 0; //violation when checking assignment operators with EOL wrap option
49          int y =
50              0;
51      }
52  
53      <
54          T extends Comparable &
55          java.io.Serializable
56      >
57      void testGenerics1()
58      {
59          Comparable
60              <
61              String
62              >
63              c = new String();
64      }
65  }
66  
67  class badCase22<T extends Foo2 &
68      Bar2> {
69  }
70  
71  class goodCase2<T extends Foo2 & Bar2> {
72  }
73  
74  class Switch2 {
75      public void test(int i, int j) {
76          switch(j) {
77          case 7:
78              return;
79          }
80          switch(i) {
81          case 1:
82              break;
83          default:
84              ;
85          }
86          for (int k : new int[]{1,2,3}) {}
87      }
88  }
89  
90  interface Foo2 {}
91  interface Bar2 {}