View Javadoc
1   /*
2   GenericWhitespace
3   
4   
5   */
6   
7   package com.puppycrawl.tools.checkstyle.checks.whitespace.genericwhitespace;
8   
9   import java.io.Serializable;
10  import java.util.ArrayList;
11  import java.util.HashMap;
12  import java.util.List;
13  import java.util.Map;
14  import java.util.concurrent.Callable;
15  import java.util.Collections;
16  class InputGenericWhitespaceDefault implements Comparable<Object>, Serializable
17  {
18      void meth()
19      {
20          List<Integer> x = new ArrayList<Integer>();
21          List<List<Integer>> y = new ArrayList<List<Integer>>();
22          List < Integer > a = new ArrayList < Integer > (); // 7 violations
23          List < List < Integer > > b = new ArrayList < List < Integer > > (); // 15 violations
24      }
25      //always 0
26      public int compareTo(Object aObject)
27      {
28          return 0;
29      }
30  
31      public static <T> Callable<T> callable(Runnable task, T result)
32      {
33          return null;
34      }
35  
36      public static<T>Callable<T> callable2(Runnable task, T result) // 2 violations
37      {
38          Map<Class<?>, Integer> x = new HashMap<Class<?>, Integer>();
39          for (final Map.Entry<Class<?>, Integer> entry : x.entrySet()) {
40              entry.getValue();
41          }
42          Class<?>[] parameterClasses = new Class<?>[0];
43          return null;
44      }
45      public int getConstructor(Class<?>... parameterTypes)
46      {
47          Collections.<Object>emptySet();
48          Collections. <Object> emptySet(); // 2 violations
49          return 666;
50      }
51  
52      <T> InputGenericWhitespaceDefault(List<T> things, int i)
53      {
54      }
55  
56      public <T> InputGenericWhitespaceDefault(List<T> things)
57      {
58      }
59  
60      public interface IntE { /*inner enum*/
61      }
62  
63      public static class IntEnumValueType<E extends Enum<E> & IntE> {
64      }
65  
66      class IntEVT2<E extends Enum<E>& IntE> { // violation ''&' is not preceded with whitespace.'
67      }
68  
69      class IntEVT3<E extends Enum<E>  & IntE> { // violation ''>' is followed by whitespace.'
70      }
71  
72      public static class IntEnumValueType4<T extends Comparable<List<T>> & IntE> {
73      }
74  
75      public void beforeAndAfter() {
76          List
77  <
78  Integer> x = new ArrayList<Integer
79  >();
80          List
81          <Integer> y = new ArrayList<Integer
82          >();
83          Map<Class<?>, Integer> a = new HashMap<Class<?>, Integer>();
84          Map<Class<?>, Integer> b = (Map<Class<?>, Integer>) a;
85      }
86      Object ok = new <String>Object();
87      Object notOkStart = new<String>Object(); // violation ''<' is not preceded with whitespace.'
88      Object notOkEnd = new <String> Object(); // violation ''>' is followed by whitespace.'
89      Object notOkStartAndEnd = new<String> Object(); // 2 violations
90      Object okWithPackage = new <String>java.lang.Object();
91      Object ok2 = new <String>Outer.Inner();
92      Object notOkSt2 = new<String>Outer.Inner(); // violation ''<' is not preceded with whitespace.'
93      Object notOkEnd2 = new <String> Outer.Inner(); // violation '>' is followed by whitespace.'
94      Object notOkStartAndEnd2 = new<String> Outer.Inner(); // 2 violations
95  }
96  interface SupplierFunction<T> extends Map<List<T>, T> {}
97  
98  class Outer {
99      static class Inner {}
100 }