View Javadoc
1   /*
2   GenericWhitespace
3   
4   
5   */
6   
7   package com.puppycrawl.tools.checkstyle.checks.whitespace.genericwhitespace;
8   
9   import java.lang.annotation.Target;
10  import java.util.ArrayList;
11  import java.util.List;
12  
13  import static java.lang.annotation.ElementType.TYPE_USE;
14  
15  public class InputGenericWhitespaceBeforeCtorInvocation {
16      List<String> music = new ArrayList<>();
17      List todo = new ArrayList<> (); // violation, ''>' is followed by whitespace.'
18  
19      Gen<String, Integer> eel = new Gen<String, Integer > ();
20      // 2 violations above:
21      //                    ''>' is followed by whitespace.'
22      //                    ''>' is preceded with whitespace.'
23  
24      Pipe pipe = new Pipe< String>() { // violation, ''<' is followed by whitespace.'
25      };
26  
27      Class<?>[] classy = new Class<?> []{}; // violation, ''>' is followed by whitespace.'
28  
29      void method() {
30          new Very.Deep<Integer>();
31          new Very.Deep.Rabbit.Hole <  Integer  > ();
32          // 4 violations above:
33          //                    ''<' is followed by whitespace.'
34          //                    ''<' is preceded with whitespace.'
35          //                    ''>' is followed by whitespace.'
36          //                    ''>' is preceded with whitespace.'
37  
38          new @A Gen<@A Gen, @A Gen> (); // violation, ''>' is followed by whitespace.'
39          new java.util.HashMap<Integer, Integer> (); // violation, ''>' is followed by whitespace.'
40          new ArrayList<Very <Gen<String,String>>> ();
41          // 2 violations above:
42          //                    ''<' is preceded with whitespace.'
43          //                    ''>' is followed by whitespace.'
44      }
45  
46      static final Very<Gen<String, String>> veryGen =
47              new Very<Gen<String, String>> () {}; // violation, ''>' is followed by whitespace.'
48  
49      <T> void mustPatTheCroc(boolean mustPat, T[] crocs) {
50          Very.swampPuppy(new Gen<String, String> ()); // violation, ''>' is followed by whitespace.'
51          if (!mustPat) {
52              mustPatTheCroc(true, new Very<?> []{}); // violation, ''>' is followed by whitespace.'
53          }
54      }
55  
56      class Gen<T, U> {}
57  
58      static class Very<Q> {
59          static void swampPuppy(Gen<String, String> croc) {}
60          static class Deep<D> {
61              static class Rabbit<R> {
62                  static class Hole<H> {
63  
64                  }
65              }
66          }
67      }
68  
69      interface Pipe<T> {
70      }
71  
72      @Target({TYPE_USE}) @interface A {}
73  }