View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule451wheretobreak;
2   
3   import java.util.Arrays;
4   import java.util.HashMap;
5   import java.util.Map;
6   
7   class InputFormattedOperatorWrap {
8     void test() {
9       int x = 1 + 2 - 3 - 4;
10      x = x + 2;
11      boolean y = true && false;
12      y = true && false;
13      y = false && true;
14      /* Note: The three tests below will be used when issue #3381 is closed */
15      Arrays.sort(null, String::compareToIgnoreCase);
16      Arrays.sort(null, String::compareToIgnoreCase);
17      Arrays.sort(null, String::compareToIgnoreCase);
18    }
19  
20    void testAssignment() {
21      int x = 0;
22      int y = 0;
23    }
24  
25    <T extends Comparable & java.io.Serializable> void testGenerics1() {
26      Comparable<String> c = new String();
27      Map<String, String> map = new HashMap<String, String>();
28  
29      boolean flag = false;
30  
31      int init = 9;
32  
33      for (Map.Entry<String, String> entry : map.entrySet()) {
34        int i = flag == true ? 1 : 2;
35      }
36  
37      if (init != 9) {
38        /* ignore */
39      }
40  
41      while (init == 10) {}
42  
43      if (init > 10) {
44        /* ignore */
45      }
46  
47      while (init < 10 || !flag) {}
48    }
49  
50    class Inner {
51      void testGenerics1() {
52        Comparable<String> c = new String();
53        Map<String, String> map = new HashMap<String, String>();
54        boolean flag = false;
55  
56        int init = 9;
57  
58        for (Map.Entry<String, String> entry : map.entrySet()) {
59          int i = flag == true ? 1 : 2;
60        }
61  
62        if (init != 9) {
63          /* ignore */
64        }
65  
66        while (init == 10) {}
67  
68        if (init > 10) {
69          /* ignore */
70        }
71  
72        while (init < 10 || !flag) {}
73      }
74    }
75  
76    Inner anon =
77        new Inner() {
78          void testGenerics1() {
79            Comparable<String> c = new String();
80            Map<String, String> map = new HashMap<String, String>();
81            boolean flag = false;
82            int init = 9;
83  
84            for (Map.Entry<String, String> entry : map.entrySet()) {
85              int i = flag == true ? 1 : 2;
86            }
87  
88            if (init != 9) {
89              /* ignore */
90            }
91  
92            while (init == 10) {}
93  
94            if (init > 10) {
95              /* ignore */
96            }
97  
98            while (init < 10 || !flag) {}
99          }
100       };
101 
102   class AsInput {
103     int abc = 0;
104     String string = "string";
105     double pi = 3.1415;
106   }
107 
108   class Ternary {
109     void foo() {
110       boolean flag = true;
111       int i = flag == true ? 1 : 2;
112       int i2 = flag == true ? 1 : 2;
113       int i3 = flag == true ? 1 : 2;
114     }
115   }
116 
117   class AssignClass {
118     void foo() {
119       int i = 0;
120       int j = 0;
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       i %= 1;
130       j %= 2;
131       i ^= 1;
132       j ^= 2;
133       i |= 1;
134       j |= 2;
135       i &= 1;
136       j &= 2;
137       i >>= 1;
138       j >>= 2;
139       i >>>= 1;
140       j >>>= 2;
141       i <<= 1;
142       j <<= 2;
143     }
144 
145     class InnerClass {
146       void foo() {
147         int i = 0;
148         int j = 0;
149         i += 1;
150         j += 2;
151         i -= 1;
152         j -= 2;
153         i /= 1;
154         j /= 2;
155         i *= 1;
156         j *= 2;
157         i %= 1;
158         j %= 2;
159         i ^= 1;
160         j ^= 2;
161         i |= 1;
162         j |= 2;
163         i &= 1;
164         j &= 2;
165         i >>= 1;
166         j >>= 2;
167         i >>>= 1;
168         j >>>= 2;
169         i <<= 1;
170         j <<= 2;
171       }
172     }
173 
174     InnerClass anon =
175         new InnerClass() {
176           void foo() {
177             int i = 0;
178             int j = 0;
179             i += 1;
180             j += 2;
181             i -= 1;
182             j -= 2;
183             i /= 1;
184             j /= 2;
185             i *= 1;
186             j *= 2;
187             i %= 1;
188             j %= 2;
189             i ^= 1;
190             j ^= 2;
191             i |= 1;
192             j |= 2;
193             i &= 1;
194             j &= 2;
195             i >>= 1;
196             j >>= 2;
197             i >>>= 1;
198             j >>>= 2;
199             i <<= 1;
200             j <<= 2;
201           }
202         };
203 
204     <T extends Comparable & java.io.Serializable> void testWrapBeforeOperator() {}
205   }
206 }