1 package com.puppycrawl.tools.checkstyle.checks.modifier.modifierorder;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.io.Serializable;
6 import java.lang.annotation.ElementType;
7 import java.lang.annotation.Target;
8 import java.util.Collection;
9 import java.util.Comparator;
10 import java.util.List;
11 import java.util.Map;
12
13 public class InputModifierOrderTypeAnnotations extends MyClass {
14
15
16 private @TypeAnnotation String hello = "Hello, World!";
17 private @TypeAnnotation final String jdk = "JDK8";
18 @TypeAnnotation private String projectName = "Checkstyle";
19
20
21 private Map.@TypeAnnotation Entry entry;
22
23 private List<@TypeAnnotation String> strings;
24
25
26 {
27 new @TypeAnnotation Object();
28 }
29
30 static {
31 new @TypeAnnotation Object();
32 }
33
34 public void foo1() {
35 new @TypeAnnotation Object();
36 }
37
38
39 public void foo2() {
40 Object myObject = new Object();
41
42 }
43
44
45 public void foo3() {
46 String myString = (@TypeAnnotation String) new Object();
47
48 }
49
50
51 private void foo4(final @TypeAnnotation String parameterName) { }
52
53
54 class MySerializableClass<T> implements @TypeAnnotation Serializable { }
55
56
57 Map<@TypeAnnotation String, @TypeAnnotation List<@TypeAnnotation String>> documents;
58
59
60 public <E extends @TypeAnnotation Comparator<E> & @TypeAnnotation Comparable> void foo5() { }
61
62
63 class Folder<F extends @TypeAnnotation File> { }
64 Collection<? super @TypeAnnotation File> c;
65 List<@TypeAnnotation ? extends Comparable<T>> unchangeable;
66
67
68 void foo6() throws @TypeAnnotation IOException { }
69
70
71 public void foo7() {
72 boolean isNonNull = "string" instanceof @TypeAnnotation String;
73
74 }
75
76 class Nested { }
77
78 class T { }
79
80
81 @Override
82 public @TypeAnnotation String toString() { return ""; }
83
84 @Override
85 @TypeAnnotation public int hashCode() { return 1; }
86
87 public @TypeAnnotation int foo8() { return 1; }
88
89 public @TypeAnnotation boolean equals(Object obj) { return super.equals(obj); }
90
91
92
93
94 @Override
95 void foo10() {
96 super.foo10();
97 }
98 }
99
100 class MyClass {
101
102
103 @MethodAnnotation void foo10() {}
104 private @MethodAnnotation void foo11() {}
105
106 public @TypeAnnotation MyClass() {}
107 @ConstructorAnnotation public MyClass(String name) {}
108 }
109
110 enum MyEnum {
111 @TypeAnnotation A;
112 }
113
114 interface IInterfacable {
115 default @TypeAnnotation String foo() {
116 return null;
117 }
118 }
119
120 @Target({
121 ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER,
122 ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
123 @interface TypeAnnotation {
124 }
125
126 @interface MethodAnnotation {}
127
128 @interface ConstructorAnnotation {}