1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
40
40
41
41
/**
42
42
* Register the necessary reflection hints so that the specified type can be
43
- * bound at runtime. Fields, constructors, properties and record components
43
+ * bound at runtime. Fields, constructors, properties, and record components
44
44
* are registered, except for a set of types like those in the {@code java.}
45
45
* package where just the type is registered. Types are discovered transitively
46
46
* on properties and record components, and generic types are registered as well.
@@ -54,8 +54,9 @@ public class BindingReflectionHintsRegistrar {
54
54
55
55
private static final String JACKSON_ANNOTATION = "com.fasterxml.jackson.annotation.JacksonAnnotation" ;
56
56
57
- private static final boolean jacksonAnnotationPresent = ClassUtils .isPresent (JACKSON_ANNOTATION ,
58
- BindingReflectionHintsRegistrar .class .getClassLoader ());
57
+ private static final boolean jacksonAnnotationPresent =
58
+ ClassUtils .isPresent (JACKSON_ANNOTATION , BindingReflectionHintsRegistrar .class .getClassLoader ());
59
+
59
60
60
61
/**
61
62
* Register the necessary reflection hints to bind the specified types.
@@ -94,8 +95,7 @@ private void registerReflectionHints(ReflectionHints hints, Set<Type> seen, Type
94
95
registerRecordHints (hints , seen , recordComponent .getAccessor ());
95
96
}
96
97
}
97
- typeHint .withMembers (
98
- MemberCategory .DECLARED_FIELDS ,
98
+ typeHint .withMembers (MemberCategory .DECLARED_FIELDS ,
99
99
MemberCategory .INVOKE_DECLARED_CONSTRUCTORS );
100
100
for (Method method : clazz .getMethods ()) {
101
101
String methodName = method .getName ();
@@ -132,8 +132,7 @@ private void registerRecordHints(ReflectionHints hints, Set<Type> seen, Method m
132
132
}
133
133
134
134
private void registerPropertyHints (ReflectionHints hints , Set <Type > seen , @ Nullable Method method , int parameterIndex ) {
135
- if (method != null && method .getDeclaringClass () != Object .class &&
136
- method .getDeclaringClass () != Enum .class ) {
135
+ if (method != null && method .getDeclaringClass () != Object .class && method .getDeclaringClass () != Enum .class ) {
137
136
hints .registerMethod (method , ExecutableMode .INVOKE );
138
137
MethodParameter methodParameter = MethodParameter .forExecutable (method , parameterIndex );
139
138
Type methodParameterType = methodParameter .getGenericParameterType ();
@@ -191,13 +190,13 @@ private void forEachJacksonAnnotation(AnnotatedElement element, Consumer<MergedA
191
190
.from (element , MergedAnnotations .SearchStrategy .TYPE_HIERARCHY )
192
191
.stream (JACKSON_ANNOTATION )
193
192
.filter (MergedAnnotation ::isMetaPresent )
194
- .forEach (action :: accept );
193
+ .forEach (action );
195
194
}
196
195
197
196
private void registerHintsForClassAttributes (ReflectionHints hints , MergedAnnotation <Annotation > annotation ) {
198
- annotation .getRoot ().asMap ().forEach ((key , value ) -> {
197
+ annotation .getRoot ().asMap ().forEach ((attributeName , value ) -> {
199
198
if (value instanceof Class <?> classValue && value != Void .class ) {
200
- if (key .equals ("builder" )) {
199
+ if (attributeName .equals ("builder" )) {
201
200
hints .registerType (classValue , MemberCategory .INVOKE_DECLARED_CONSTRUCTORS ,
202
201
MemberCategory .INVOKE_DECLARED_METHODS );
203
202
}
@@ -208,6 +207,7 @@ private void registerHintsForClassAttributes(ReflectionHints hints, MergedAnnota
208
207
});
209
208
}
210
209
210
+
211
211
/**
212
212
* Inner class to avoid a hard dependency on Kotlin at runtime.
213
213
*/
0 commit comments