1   package com.puppycrawl.tools.checkstyle.checks.annotation.annotationlocation;
2   
3   import java.lang.annotation.ElementType;
4   import java.lang.annotation.Target;
5   
6   public class InputAnnotationLocationDeprecatedAndCustom {
7       @Deprecated // <--class, separate line
8       public class Annotation
9       {
10          @Deprecated // <--method, separate line
11          public void test(@MyAnnotation String s) { // <--parameter, same line
12              @MyAnnotation // <--variable, separate line
13              Integer i;
14              for (@MyAnnotation char c : s.toCharArray()) { // <--variable in for each, same line
15              }
16          }
17      }
18  
19      public class Test {
20          public void foo1() {
21              try {
22                  // some code
23              }
24              catch (@MyAnnotation Exception ex) {
25  
26              }
27          }
28  
29          public void foo2() {
30              for (@MyAnnotation int i = 0; i < 10; i++) {
31  
32              }
33          }
34  
35          public void foo3() {
36              MathOperation c = (@MyAnnotation int a, @MyAnnotation int b) -> a + b;
37          }
38  
39          public void foo4(@MyAnnotation int a, @MyAnnotation int b) {}
40  
41          public void foo5(@SuppressWarnings("unchecked") int a) {}
42      }
43  
44      interface MathOperation {
45          int operation(int a, int b);
46      }
47  
48      @Target(ElementType.TYPE_USE)
49      public @interface MyAnnotation {}
50  }