View Javadoc
1   /*
2   NoWhitespaceAfter
3   allowLineBreaks = (default)true
4   tokens = ARRAY_INIT, AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, BNOT, LNOT, DOT, TYPECAST, \
5            ARRAY_DECLARATOR, INDEX_OP, LITERAL_SYNCHRONIZED, METHOD_REF
6   
7   
8   */
9   
10  package com.puppycrawl.tools.checkstyle.checks.whitespace.nowhitespaceafter;
11  
12  import java.lang.annotation.ElementType;
13  import java.lang.annotation.Retention;
14  import java.lang.annotation.RetentionPolicy;
15  import java.lang.annotation.Target;
16  import java.util.Map;
17  
18  @Target(ElementType.TYPE_USE)
19  @interface NonNull {}
20  
21  @Retention(RetentionPolicy.CLASS)
22  @Target({ElementType.TYPE_USE})
23  @interface MyAnnotation {
24  }
25  public class InputNoWhitespaceAfterArrayDeclarationsAndAnno {
26  
27      @NonNull int @NonNull[] @NonNull[] field1; // ok
28      @NonNull int @NonNull [] @NonNull [] field2; // ok
29      int[] array[] = new int[2][2]; // ok
30      int array2[][][] = new int[3][3][3]; // ok
31  
32      public void foo(final char @NonNull [] param) {} // ok
33  
34      public void m1(@NonNull String @NonNull ... vararg) {
35      }
36  
37      public String m2()@NonNull[]@NonNull[] {
38          return null;
39      }
40  
41      public void instructions() {
42          // annotations
43          Map.@MyAnnotation Entry e;
44          String str = (@MyAnnotation String)"";
45          (new Inner3()).<@MyAnnotation String>m();
46          Object arr = new @MyAnnotation String@MyAnnotation[3];
47          for (String a@MyAnnotation[] : m2()) {
48          }
49          Object arr2 = new @MyAnnotation int[3];
50      }
51  
52      static class Inner3<T> {
53          public void m() {
54          }
55      }
56  
57  }