Skip to content

Commit 3cd5626

Browse files
committed
Format code and final fields for ProcessingContext
1 parent 6e0db66 commit 3cd5626

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

http-generator-core/src/main/java/io/avaje/http/generator/core/ProcessingContext.java

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,22 @@
2525

2626
public class ProcessingContext {
2727

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<>();
3838

3939
public static void init(ProcessingEnvironment env, PlatformAdapter adapter) {
4040
init(env, adapter, true);
4141
}
4242

43-
public static void init(
44-
ProcessingEnvironment env, PlatformAdapter adapter, boolean generateOpenAPI) {
43+
public static void init(ProcessingEnvironment env, PlatformAdapter adapter, boolean generateOpenAPI) {
4544
READ_ADAPTER.set(adapter);
4645
MESSAGER.set(env.getMessager());
4746
FILER.set(env.getFiler());
@@ -96,12 +95,16 @@ public static void logError(Element e, String msg, Object... args) {
9695
MESSAGER.get().printMessage(Diagnostic.Kind.ERROR, String.format(msg, args), e);
9796
}
9897

99-
/** Create a file writer for the given class name. */
98+
/**
99+
* Create a file writer for the given class name.
100+
*/
100101
public static JavaFileObject createWriter(String cls, Element origin) throws IOException {
101102
return FILER.get().createSourceFile(cls, origin);
102103
}
103104

104-
/** Create a file writer for the META-INF services file. */
105+
/**
106+
* Create a file writer for the META-INF services file.
107+
*/
105108
public static FileObject createMetaInfWriter(String target) throws IOException {
106109
return FILER.get().createResource(StandardLocation.CLASS_OUTPUT, "", target);
107110
}
@@ -125,20 +128,20 @@ public static TypeMirror asMemberOf(DeclaredType declaredType, Element element)
125128
public static List<ExecutableElement> superMethods(Element element, String methodName) {
126129
final Types types = TYPES.get();
127130
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());
142145
}
143146

144147
public static PlatformAdapter platform() {

0 commit comments

Comments
 (0)