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