25
25
26
26
public class ProcessingContext {
27
27
28
- private static ThreadLocal <PlatformAdapter > READ_ADAPTER = new ThreadLocal <>();
29
- private static ThreadLocal <Messager > MESSAGER = new ThreadLocal <>();
30
- private static ThreadLocal <Filer > FILER = new ThreadLocal <>();
31
- private static ThreadLocal <Elements > ELEMENTS = new ThreadLocal <>();
32
- private static ThreadLocal <Types > TYPES = new ThreadLocal <>();
33
- private static ThreadLocal <Boolean > OPENAPI_AVAILABLE = ThreadLocal .withInitial (() -> false );
34
- private static ThreadLocal <DocContext > DOC_CONTEXT = new ThreadLocal <>();
35
- private static ThreadLocal <Boolean > USE_COMPONENT = ThreadLocal .withInitial (() -> false );
36
- private static ThreadLocal <Boolean > USE_JAVAX = ThreadLocal .withInitial (() -> false );
37
- private static ThreadLocal <String > DI_ANNOTATION = new ThreadLocal <>();
28
+ private static final ThreadLocal <PlatformAdapter > READ_ADAPTER = new ThreadLocal <>();
29
+ private static final ThreadLocal <Messager > MESSAGER = new ThreadLocal <>();
30
+ private static final ThreadLocal <Filer > FILER = new ThreadLocal <>();
31
+ private static final ThreadLocal <Elements > ELEMENTS = new ThreadLocal <>();
32
+ private static final ThreadLocal <Types > TYPES = new ThreadLocal <>();
33
+ private static final ThreadLocal <Boolean > OPENAPI_AVAILABLE = ThreadLocal .withInitial (() -> false );
34
+ private static final ThreadLocal <DocContext > DOC_CONTEXT = new ThreadLocal <>();
35
+ private static final ThreadLocal <Boolean > USE_COMPONENT = ThreadLocal .withInitial (() -> false );
36
+ private static final ThreadLocal <Boolean > USE_JAVAX = ThreadLocal .withInitial (() -> false );
37
+ private static final ThreadLocal <String > DI_ANNOTATION = new ThreadLocal <>();
38
38
39
39
public static void init (ProcessingEnvironment env , PlatformAdapter adapter ) {
40
40
init (env , adapter , true );
41
41
}
42
42
43
- public static void init (
44
- ProcessingEnvironment env , PlatformAdapter adapter , boolean generateOpenAPI ) {
43
+ public static void init (ProcessingEnvironment env , PlatformAdapter adapter , boolean generateOpenAPI ) {
45
44
READ_ADAPTER .set (adapter );
46
45
MESSAGER .set (env .getMessager ());
47
46
FILER .set (env .getFiler ());
@@ -96,12 +95,16 @@ public static void logError(Element e, String msg, Object... args) {
96
95
MESSAGER .get ().printMessage (Diagnostic .Kind .ERROR , String .format (msg , args ), e );
97
96
}
98
97
99
- /** Create a file writer for the given class name. */
98
+ /**
99
+ * Create a file writer for the given class name.
100
+ */
100
101
public static JavaFileObject createWriter (String cls , Element origin ) throws IOException {
101
102
return FILER .get ().createSourceFile (cls , origin );
102
103
}
103
104
104
- /** Create a file writer for the META-INF services file. */
105
+ /**
106
+ * Create a file writer for the META-INF services file.
107
+ */
105
108
public static FileObject createMetaInfWriter (String target ) throws IOException {
106
109
return FILER .get ().createResource (StandardLocation .CLASS_OUTPUT , "" , target );
107
110
}
@@ -125,20 +128,20 @@ public static TypeMirror asMemberOf(DeclaredType declaredType, Element element)
125
128
public static List <ExecutableElement > superMethods (Element element , String methodName ) {
126
129
final Types types = TYPES .get ();
127
130
return types .directSupertypes (element .asType ()).stream ()
128
- .filter (type -> !type .toString ().contains ("java.lang.Object" ))
129
- .map (
130
- superType -> {
131
- final var superClass = (TypeElement ) types .asElement (superType );
132
- for (final ExecutableElement method :
133
- ElementFilter .methodsIn (ELEMENTS .get ().getAllMembers (superClass ))) {
134
- if (method .getSimpleName ().contentEquals (methodName )) {
135
- return method ;
136
- }
137
- }
138
- return null ;
139
- })
140
- .filter (Objects ::nonNull )
141
- .collect (Collectors .toList ());
131
+ .filter (type -> !type .toString ().contains ("java.lang.Object" ))
132
+ .map (
133
+ superType -> {
134
+ final var superClass = (TypeElement ) types .asElement (superType );
135
+ for (final ExecutableElement method :
136
+ ElementFilter .methodsIn (ELEMENTS .get ().getAllMembers (superClass ))) {
137
+ if (method .getSimpleName ().contentEquals (methodName )) {
138
+ return method ;
139
+ }
140
+ }
141
+ return null ;
142
+ })
143
+ .filter (Objects ::nonNull )
144
+ .collect (Collectors .toList ());
142
145
}
143
146
144
147
public static PlatformAdapter platform () {
0 commit comments