View Javadoc
1   /*
2   AnnotationLocation
3   allowSamelineMultipleAnnotations = (default)false
4   allowSamelineSingleParameterlessAnnotation = false
5   allowSamelineParameterizedAnnotation = (default)false
6   tokens = CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, \
7            VARIABLE_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF
8   
9   
10  */
11  
12  package com.puppycrawl.tools.checkstyle.checks.annotation.annotationlocation;
13  
14  import java.lang.annotation.ElementType;
15  import java.lang.annotation.Target;
16  
17  public class InputAnnotationLocationDeprecatedAndCustom {
18      @Deprecated
19      public class Annotation
20      {
21          @Deprecated // <--method, separate line
22          public void test(@MyAnnotation String s) {
23              @MyAnnotation // <--variable, separate line
24              Integer i;
25              for (@MyAnnotation char c : s.toCharArray()) {
26              }
27          }
28      }
29  
30      public class Test {
31          public void foo1() {
32              try {
33                  // some code
34              }
35              catch (@MyAnnotation Exception ex) {
36  
37              }
38          }
39  
40          public void foo2() {
41              for (@MyAnnotation int i = 0; i < 10; i++) {
42  
43              }
44          }
45  
46          public void foo3() {
47              MathOperation c = (@MyAnnotation int a, @MyAnnotation int b) -> a + b;
48          }
49  
50          public void foo4(@MyAnnotation int a, @MyAnnotation int b) {}
51  
52          public void foo5(@SuppressWarnings("unchecked") int a) {}
53      }
54  
55      interface MathOperation {
56          int operation(int a, int b);
57      }
58  
59      @Target(ElementType.TYPE_USE)
60      public @interface MyAnnotation {}
61  }