View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;
2   
3   import java.io.IOException;
4   import java.io.StringWriter;
5   import java.io.Writer;
6   
7   /** some javadoc. */
8   public class InputFormattedParenPad {
9     boolean fooo = this.bar((true && false) && true);
10  
11    String foo() {
12      return ((Object) bar((1 > 2) ? ((3 < 4) ? false : true) : ((1 == 1) ? false : true)))
13          .toString();
14    }
15  
16    /** some javadoc. */
17    @MyAnnotation
18    public boolean bar(boolean a) {
19      assert (true);
20      return true;
21    }
22  
23    class ParenPadNoSpace {
24      ParenPadNoSpace() {
25        this(0);
26      }
27  
28      ParenPadNoSpace(int i) {
29        super();
30      }
31  
32      @SuppressWarnings("")
33      void method(boolean status) {
34        try (Writer writer = new StringWriter()) {
35          do {
36            writer.append("a");
37          } while (status);
38        } catch (IOException e) {
39          while (status) {
40            for (int i = 0; i < (long) (2 * (4 / 2)); i++) {
41              if (i > 2) {
42                synchronized (this) {
43                  switch (i) {
44                    case 3:
45                    case (4):
46                    case 5:
47                      break;
48                    default:
49                  }
50                }
51              }
52            }
53          }
54        }
55      }
56    }
57  
58    class ParenPadSpaceLeft {
59      ParenPadSpaceLeft() {
60        this(0);
61      }
62  
63      ParenPadSpaceLeft(int i) {
64        super();
65      }
66  
67      @SuppressWarnings("")
68      void method(boolean status) {
69        try (Writer writer = new StringWriter()) {
70          do {
71            writer.append("a");
72          } while (status);
73        } catch (IOException e) {
74          while (status) {
75            for (int i = 0; i < (long) (2 * (4 / 2)); i++) {
76              if (i > 2) {
77                synchronized (this) {
78                  switch (i) {
79                    case 3:
80                    case (4):
81                    case 5:
82                      break;
83                    default:
84                  }
85                }
86              }
87            }
88          }
89        }
90      }
91    }
92  
93    class ParenPadSpaceRight {
94      ParenPadSpaceRight() {
95        this(0);
96      }
97  
98      ParenPadSpaceRight(int i) {
99        super();
100     }
101 
102     @SuppressWarnings("")
103     void method(boolean status) {
104       try (Writer writer = new StringWriter()) {
105         do {
106           writer.append("a");
107         } while (status);
108       } catch (IOException e) {
109         while (status) {
110           for (int i = 0; i < (long) (2 * (4 / 2)); i++) {
111             if (i > 2) {
112               synchronized (this) {
113                 switch (i) {
114                   case 3:
115                   case (4):
116                   case 5:
117                     break;
118                   default:
119                 }
120               }
121             }
122           }
123         }
124       }
125     }
126   }
127 
128   enum MyEnum {
129     SOME_CONSTANT() {
130       final int testing = 2 * (4 / 2);
131     };
132 
133     private Object exam;
134 
135     private static String getterName(Exception t) {
136       if (t instanceof ClassNotFoundException) {
137         return ((ClassNotFoundException) t).getMessage();
138       } else {
139         return "?";
140       }
141     }
142 
143     /** some javadoc. */
144     public void myMethod() {
145       String s = "test";
146       Object o = s;
147       ((String) o).length();
148       ((String) o).length();
149     }
150 
151     /** some javadoc. */
152     public void crisRon() {
153       Object leo = "messi";
154       Object ibra = leo;
155       ((String) leo).compareTo((String) ibra);
156       Math.random();
157     }
158 
159     /** some javadoc. */
160     public void intStringConv() {
161       Object a = 5;
162       Object b = "string";
163       int w = Integer.parseInt((String) a);
164       int x = Integer.parseInt((String) a);
165       double y = Double.parseDouble((String) a);
166       float z = Float.parseFloat((String) a);
167       String d = ((String) b);
168     }
169 
170     /** some javadoc. */
171     public int something(Object o) {
172       if (o == null || !(o instanceof Float)) {
173         return -1;
174       }
175       return Integer.valueOf(22).compareTo((Integer) o);
176     }
177 
178     private void launch(Integer number) {
179       String myInt = (number.toString() + '\0');
180       boolean result = number == 123;
181     }
182 
183     /** some javadoc. */
184     public String testing() {
185       return (this.exam != null) ? ((Enum) this.exam).name() : null;
186     }
187 
188     Object stringReturnValue(Object result) {
189       if (result instanceof String) {
190         result = ((String) result).length();
191       }
192       return result;
193     }
194 
195     private void except() {
196       java.util.ArrayList<Integer> arrlist = new java.util.ArrayList<Integer>(5);
197       arrlist.add(20);
198       arrlist.add(15);
199       arrlist.add(30);
200       arrlist.add(45);
201       try {
202         (arrlist).remove(2);
203       } catch (IndexOutOfBoundsException x) {
204         x.getMessage();
205       }
206       org.junit.Assert.assertThat("123", org.hamcrest.CoreMatchers.is("123"));
207       org.junit.Assert.assertThat("Help! Integers don't work", 0, org.hamcrest.CoreMatchers.is(1));
208     }
209 
210     private void tryWithResources() throws Exception {
211       try (AutoCloseable a = null) {
212         /* foo */
213       }
214       try (AutoCloseable a = null;
215           AutoCloseable b = null) {
216         /* foo */
217       }
218       try (AutoCloseable a = null;
219           AutoCloseable b = null) {
220         /* foo */
221       }
222       try (AutoCloseable a = null;
223           AutoCloseable b = null) {
224         /* foo */
225       }
226       try (AutoCloseable a = null) {
227         /* foo */
228       }
229       try (AutoCloseable a = null;
230           AutoCloseable b = null) {
231         /* foo */
232       }
233     }
234   }
235 
236   @interface MyAnnotation {
237     String someField() default "Hello world";
238   }
239 }