View Javadoc
1   /*
2   AnnotationLocation
3   allowSamelineMultipleAnnotations = (default)false
4   allowSamelineSingleParameterlessAnnotation = (default)true
5   allowSamelineParameterizedAnnotation = (default)false
6   tokens = CLASS_DEF, CTOR_DEF, VARIABLE_DEF
7   
8   
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.annotation.annotationlocation;
12  
13  import java.lang.annotation.ElementType;
14  import java.lang.annotation.Repeatable;
15  import java.lang.annotation.Target;
16  
17  @ClassAnnotation(value = "foo")
18    @ClassAnnotation // violation '.* incorrect .* level 2, .* should be 0.'
19  // violation below 'Annotation 'ClassAnnotation' should be alone on line.'
20  @ClassAnnotation("bar") class InputAnnotationLocationClass {
21  
22      @ClassAnnotation(value = "foo")
23        @ClassAnnotation // violation '.* incorrect .* level 6, .* should be 4.'
24      @ClassAnnotation("bar") Object field; // violation '.* should be alone on line.'
25  
26      @ClassAnnotation(value = "foo")
27        @ClassAnnotation // violation '.* incorrect .* level 6, .* should be 4.'
28      // violation below 'Annotation 'ClassAnnotation' should be alone on line.'
29      @ClassAnnotation("bar") InputAnnotationLocationClass() {
30      }
31  
32  }
33  
34  @Repeatable(ClassAnnotations.class)
35  @Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.TYPE})
36  @interface ClassAnnotation {
37  
38      String value() default "";
39  
40  }
41  
42  @Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.TYPE})
43  @interface ClassAnnotations {
44  
45      ClassAnnotation[] value();
46  
47  }