code: /*
  WhitespaceAround
  allowEmptyConstructors = (default)false
  allowEmptyMethods = (default)false
  allowEmptyTypes = (default)false
  allowEmptyLoops = (default)false
  allowEmptyLambdas = (default)false
  allowEmptyCatches = (default)false
  ignoreEnhancedForColon = (default)true
  tokens = (default)ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, \
           BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND, \
           LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, \
           LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, \
           LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, \
           NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, \
           SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND
  
  
  */
  
  package com . puppycrawl
      .tools.
      checkstyle.checks.whitespace.whitespacearound;
  
  /**
   * Class for testing whitespace issues.
   * violation missing author tag
   **/
  class InputWhitespaceAroundKeywordsAndOperators
  {
      /** ignore assignment **/
      private int mVar1=1; // 2 violations
      /** ignore assignment **/
      private int mVar2 =1; // violation ''=' is not followed by whitespace'
      /** Should be ok **/
      private int mVar3 = 1;
  
      /** method **/
      void method1()
      {
          final int a = 1;
          int b= 1; // violation ''=' is not preceded with whitespace'
          b=1; // 2 violations
          b+=1; // 2 violations
          b -=- 1 + (+ b); // violation ''-=' is not followed by whitespace'
          b = b ++ + b --; // Ignore 1
          b = ++ b - -- b; // Ignore 1
      }
  
      /** method **/
      void method2()
      {
          synchronized(this) { // violation ''synchronized' is not followed by whitespace'
          }
          try{ // 2 violations
          }
          catch(RuntimeException e){ // 2 violations
          }
      }
  
      /**
         skip blank lines between comment and code,
         should be ok
      **/
  
  
      private int mVar4 = 1;
  
  
      /** test WS after void return */
      private void fastExit()
      {
          boolean complicatedStuffNeeded = true;
          if( !complicatedStuffNeeded ) // violation ''if' is not followed by whitespace'
          {
              return; // should not complain about missing WS after return
          }
          else
          {
              // do complicated stuff
          }
      }
  
  
      /** test WS after non void return
       @return 2
      */
      private int nonVoid()
      {
          if ( true )
          {
              return(2); // violation ''return' is not followed by whitespace'
          }
          else
          {
              return 2; // this is ok
          }
      }
  
      /** test casts **/
      private void testCasts()
      {
          Object o = (Object) new Object(); // ok
          o = (Object)o;
          o = ( Object ) o; // ok
          o = (Object)
              o; // ok
      }
  
      /** test questions **/
      private void testQuestions()
      {
          boolean b = (1 == 2)?true:false; // 4 violations
          b = (1==2) ? false : true; // 2 violations
      }
  
      /** star test **/
      private void starTest()
      {
          int x = 2 *3* 4; // 2 violations
      }
  
      /** boolean test **/
      private void boolTest()
      {
          boolean a = true;
          boolean x = ! a;
          int z = ~1 + ~ 2;
      }
  
      /** division test **/
      private void divTest()
      {
          int a = 4 % 2;
          int b = 4% 2; // violation ''%' is not preceded with whitespace'
          int c = 4 %2; // violation ''%' is not followed by whitespace'
          int d = 4%2; // 2 violations
          int e = 4 / 2;
          int f = 4/ 2; // violation ''/' is not preceded with whitespace'
          int g = 4 /2; // violation ''/' is not followed by whitespace'
          int h = 4/2; // 2 violations
      }
  
      /** @return dot test **/
      private java .lang.  String dotTest()
      {
          Object o = new java.lang.Object();
          o.
              toString();
          o
              .toString();
          o . toString();
          return o.toString();
      }
  
      /** assert statement test */
      public void assertTest()
      {
          // OK
          assert true;
  
          // OK
          assert true : "Whups";
  
          // evil colons, should be OK
          assert "OK".equals(null) ? false : true : "Whups";
  
          // missing WS around assert
          assert(true); // violation ''assert' is not followed by whitespace'
  
          // missing WS around colon
          assert true:"Whups"; // 2 violations
      }
  
      /** another check */
      void donBradman(Runnable aRun)
      {
          donBradman(new Runnable() {
              public void run() {
              }
          });
  
          final Runnable r = new Runnable() {
              public void run() {
              }
          };
      }
  
      /** rfe 521323, detect whitespace before ';' */
      void rfe521323()
      {
          doStuff() ;
          //       ^ whitespace
          for (int i = 0 ; i < 5; i++) {
              //        ^ whitespace
          }
      }
  
  
      /** bug 806243 (NoWhitespaceBeforeCheck violation for anonymous inner class) */
      private int i ;
      //           ^ whitespace
      private int i1, i2, i3 ;
      //                    ^ whitespace
      private int i4, i5, i6;
  
      /** bug 806243 (NoWhitespaceBeforeCheck violation for anonymous inner class) */
      void bug806243()
      {
          Object o = new InputWhitespaceAroundKeywordsAndOperators() {
              private int j ;
              //           ^ whitespace
          };
      }
  
      void doStuff() {
      }
  }
  
  /**
   * Bug 806242 (NoWhitespaceBeforeCheck violation with an interface).
   * @author o_sukhodolsky
   * @version 1.0
   */
  interface IFoo
  {
      void foo() ;
      //        ^ whitespace
  }
  
  /**
   * Avoid Whitespace violations in for loop.
   * @author lkuehne
   * @version 1.0
   */
  class SpecialCasesInForLoop
  {
      void forIterator()
      {
          // avoid conflict between WhiteSpaceAfter ';' and ParenPad(nospace)
          for (int i = 0; i++ < 5;) {
          //                  ^ no whitespace
      }
  
          // bug 895072
      // avoid conflict between ParenPad(space) and NoWhiteSpace before ';'
      int i = 0;
      for ( ; i < 5; i++ ) {
      //   ^ whitespace
      }
          for (int anInt : getSomeInts()) {
              //Should be ignored
          }
      }
  
      int[] getSomeInts() {
          int i = (int) ( 2 / 3 );
          return null;
      }
  
      public void myMethod() {
          new Thread() {
              public void run() {
              }
          }.start();
      }
  
      public void foo(java.util.List<? extends String[]> bar, Comparable<? super Object[]> baz) { }
  
      public void mySuperMethod() {
          Runnable[] runs = new Runnable[] {new Runnable() {
                  public void run() {
                  }
              },
              new Runnable() {
                  public void run() {
                  }
              }}; // violation ''}' is not followed by whitespace'
          runs[0]
  .
   run()
  ;
      }
  
      public void testNullSemi() {
          return ;
      }
  
      public void register(Object obj) { }
  
      public void doSomething(String args[]) {
          register(boolean[].class);
          register( args );
      }
  
      public void parentheses() {
          testNullSemi
  (
  )
  ;
      }
  
      public static void testNoWhitespaceBeforeEllipses(String ... args) {
      }
      public String test() {
          int pc = 0;
          return ((100000+pc)+"").substring(1); // 4 violations
      }
  }
  