View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule451wheretobreak;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   class InputFormattedMethodParamPad {
7     class Inner {
8       void testGenerics1() {
9         Comparable<String> c = new String();
10        Map<String, String> map = new HashMap<String, String>();
11        boolean flag = false;
12  
13        int init = 9;
14      }
15    }
16  
17    Inner anon =
18        new Inner() {
19          void testGenerics1() {
20            Comparable<String> c = new String();
21            Map<String, String> map = new HashMap<String, String>();
22            boolean flag = false;
23            int init = 9;
24          }
25        };
26  }
27  
28  // violation below 'Top-level class ExtraAsInput1 has to reside in its own source file.'
29  class ExtraAsInput1 {
30    int abc = 0;
31    String string = "string";
32    double pi = 3.1415;
33  }
34  
35  // violation below 'Top-level class ExtraTernary2 has to reside in its own source file.'
36  class ExtraTernary2 {
37    void foo() {
38      boolean flag = true;
39      int i2 = flag == true ? 1 : 2;
40      int i3 = flag == true ? 1 : 2;
41    }
42  }
43  
44  // violation below 'Top-level class ExtraAssignClass3 has to reside in its own source file.'
45  class ExtraAssignClass3 {
46    void foo() {
47      int i = 0;
48      int j = 0;
49      i += 1;
50      j += 2;
51      i -= 1;
52      j -= 2;
53      i /= 1;
54      j /= 2;
55      i *= 1;
56      j *= 2;
57      i %= 1;
58      j %= 2;
59      i ^= 1;
60      j ^= 2;
61      i |= 1;
62      j |= 2;
63      i &= 1;
64      j &= 2;
65      i >>= 1;
66      j >>= 2;
67      i >>>= 1;
68      j >>>= 2;
69      i <<= 1;
70      j <<= 2;
71    }
72  
73    class InnerClass {
74      void foo() {
75        int i = 0;
76        int j = 0;
77        i += 1;
78        j += 2;
79        i -= 1;
80        j -= 2;
81        i /= 1;
82        j /= 2;
83        i *= 1;
84        j *= 2;
85        i %= 1;
86        j %= 2;
87        i ^= 1;
88        j ^= 2;
89        i |= 1;
90        j |= 2;
91        i &= 1;
92        j &= 2;
93        i >>= 1;
94        j >>= 2;
95        i >>>= 1;
96        j >>>= 2;
97        i <<= 1;
98        j <<= 2;
99      }
100   }
101 
102   InnerClass anon =
103       new InnerClass() {
104         void foo() {
105           int i = 0;
106           int j = 0;
107           i += 1;
108           j += 2;
109           i -= 1;
110           j -= 2;
111           i /= 1;
112           j /= 2;
113           i *= 1;
114           j *= 2;
115           i %= 1;
116           j %= 2;
117           i ^= 1;
118           j ^= 2;
119           i |= 1;
120           j |= 2;
121           i &= 1;
122           j &= 2;
123           i >>= 1;
124           j >>= 2;
125           i >>>= 1;
126           j >>>= 2;
127           i <<= 1;
128           j <<= 2;
129         }
130       };
131 
132   enum TestEnum {
133     FIRST() {},
134 
135     SECOND() {}
136   }
137 }