1 /* 2 AnnotationOnSameLine 3 tokens = CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, \ 4 VARIABLE_DEF, PARAMETER_DEF, ANNOTATION_DEF, TYPECAST, LITERAL_THROWS, \ 5 IMPLEMENTS_CLAUSE, TYPE_ARGUMENT, LITERAL_NEW, DOT, ANNOTATION_FIELD_DEF 6 7 8 */ 9 10 package com.puppycrawl.tools.checkstyle.checks.annotation.annotationonsameline; 11 12 public class InputAnnotationOnSameLineCheckTokensOnMethodAndVar { 13 14 @Annotation3 int x; 15 16 int y; 17 18 19 20 @Annotation3 // violation, "should be on the same line with its target." 21 @SomeClass2.Annotation // violation, "should be on the same line with its target." 22 @java.lang.Deprecated // violation, "should be on the same line with its target." 23 public int getX() { 24 return (int) x; 25 } 26 27 // 2 violations 3 lines below: 28 // 'Annotation 'Annotation4' should be on the same line with its target.' 29 // 'Annotation 'Annotation3' should be on the same line with its target.' 30 @Annotation4 @Annotation3 31 public int field; 32 33 public 34 @Annotation3 int field2; 35 } 36 37 class SomeClass2 { 38 39 @interface Annotation {} 40 } 41 42 @interface Annotation3 {} 43 @interface Annotation4 {}