View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule451wheretobreak;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   class InputMethodParamPad {
7     class Inner {
8       void testGenerics1
9       () { // violation ''(' should be on the previous line.'
10        Comparable
11            <
12            String
13            >
14            c = new String();
15        Map<String, String> map = new HashMap<String, String>();
16        boolean flag = false;
17  
18        int init = 9;
19      }
20    }
21  
22    Inner anon = new Inner
23        () {
24          // 2 violations above:
25          //  ''new lparen' has incorrect indentation level 6, expected level should be 2.'
26          //  ''(' should be on the previous line.'
27          void testGenerics1
28          () { // violation ''(' should be on the previous line.'
29            Comparable
30                <
31                String
32                >
33                c = new String();
34            Map<String, String> map = new HashMap<String, String>();
35            boolean flag = false;
36            int init = 9;
37          }
38        };
39  }
40  
41  // violation below 'Top-level class AsInput1 has to reside in its own source file.'
42  class AsInput1 {
43    int abc = 0;
44    String string
45        = "string";
46    double pi =
47            3.1415;
48  }
49  
50  // violation below 'Top-level class Ternary2 has to reside in its own source file.'
51  class Ternary2 {
52    void foo() {
53      boolean flag = true;
54      int i2 = flag == true
55              ?
56              1
57              :
58              2;
59      int i3 = flag == true
60              ? 1
61              : 2;
62    }
63  }
64  
65  // violation below 'Top-level class AssignClass3 has to reside in its own source file.'
66  class AssignClass3 {
67    void foo() {
68      int i = 0;
69      int j = 0;
70      i +=
71              1;
72      j
73           += 2;
74      i -=
75              1;
76      j
77           -= 2;
78      i /=
79              1;
80      j
81           /= 2;
82      i *=
83              1;
84      j
85           *= 2;
86      i %=
87              1;
88      j
89           %= 2;
90      i ^=
91              1;
92      j
93           ^= 2;
94      i |=
95              1;
96      j
97           |= 2;
98      i &=
99              1;
100     j
101          &= 2;
102     i >>=
103             1;
104     j
105         >>= 2;
106     i >>>=
107             1;
108     j
109         >>>= 2;
110     i <<=
111             1;
112     j
113         <<= 2;
114   }
115 
116   class InnerClass {
117     void foo() {
118       int i = 0;
119       int j = 0;
120       i += 1;
121       j += 2;
122       i -= 1;
123       j -= 2;
124       i /= 1;
125       j /= 2;
126       i *= 1;
127       j *= 2;
128       i %= 1;
129       j %= 2;
130       i ^= 1;
131       j ^= 2;
132       i |= 1;
133       j |= 2;
134       i &= 1;
135       j &= 2;
136       i >>= 1;
137       j >>= 2;
138       i >>>= 1;
139       j >>>= 2;
140       i <<= 1;
141       j <<= 2;
142     }
143   }
144 
145   InnerClass anon =
146       new InnerClass() {
147         void foo() {
148           int i = 0;
149           int j = 0;
150           i +=
151                   1;
152           j
153                += 2;
154           i -=
155                   1;
156           j
157                -= 2;
158           i /=
159                   1;
160           j
161                /= 2;
162           i *=
163                   1;
164           j
165                *= 2;
166           i %=
167                   1;
168           j
169                %= 2;
170           i ^=
171                   1;
172           j
173                ^= 2;
174           i |=
175                   1;
176           j
177                |= 2;
178           i &=
179                   1;
180           j
181                &= 2;
182           i >>=
183                   1;
184           j
185               >>= 2;
186           i >>>=
187                   1;
188           j
189               >>>= 2;
190           i <<=
191                   1;
192           j
193               <<= 2;
194         }
195       };
196 
197   enum TestEnum {
198     FIRST () {}, // violation ''(' is preceded with whitespace.'
199 
200     SECOND
201         () {} // violation ''(' should be on the previous line.'
202   }
203 }