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