31
31
32
32
import org .springframework .beans .BeanUtils ;
33
33
import org .springframework .core .log .LogMessage ;
34
+ import org .springframework .core .type .AnnotationMetadata ;
34
35
import org .springframework .core .type .MethodMetadata ;
35
- import org .springframework .data .type .MethodsMetadata ;
36
- import org .springframework .data .type .classreading .MethodsMetadataReaderFactory ;
36
+ import org .springframework .core .type .classreading .SimpleMetadataReaderFactory ;
37
37
import org .springframework .data .util .StreamUtils ;
38
38
import org .springframework .util .Assert ;
39
39
import org .springframework .util .ClassUtils ;
@@ -133,7 +133,7 @@ private static class PropertyDescriptorSource {
133
133
private static final Log logger = LogFactory .getLog (PropertyDescriptorSource .class );
134
134
135
135
private final Class <?> type ;
136
- private final Optional <MethodsMetadata > metadata ;
136
+ private final Optional <AnnotationMetadata > metadata ;
137
137
138
138
/**
139
139
* Creates a new {@link PropertyDescriptorSource} for the given type.
@@ -179,15 +179,15 @@ private Stream<PropertyDescriptor> collectDescriptors() {
179
179
}
180
180
181
181
/**
182
- * Returns a {@link Stream} of {@link PropertyDescriptor} ordered following the given {@link MethodsMetadata} only
183
- * returning methods seen by the given {@link MethodsMetadata }.
182
+ * Returns a {@link Stream} of {@link PropertyDescriptor} ordered following the given {@link AnnotationMetadata}
183
+ * only returning methods seen by the given {@link AnnotationMetadata }.
184
184
*
185
185
* @param source must not be {@literal null}.
186
186
* @param metadata must not be {@literal null}.
187
187
* @return
188
188
*/
189
189
private static Stream <PropertyDescriptor > filterAndOrder (Stream <PropertyDescriptor > source ,
190
- MethodsMetadata metadata ) {
190
+ AnnotationMetadata metadata ) {
191
191
192
192
var orderedMethods = getMethodOrder (metadata );
193
193
@@ -201,12 +201,12 @@ private static Stream<PropertyDescriptor> filterAndOrder(Stream<PropertyDescript
201
201
}
202
202
203
203
/**
204
- * Returns a {@link Stream} of interfaces using the given {@link MethodsMetadata } as primary source for ordering.
204
+ * Returns a {@link Stream} of interfaces using the given {@link AnnotationMetadata } as primary source for ordering.
205
205
*
206
206
* @param metadata must not be {@literal null}.
207
207
* @return
208
208
*/
209
- private Stream <Class <?>> fromMetadata (MethodsMetadata metadata ) {
209
+ private Stream <Class <?>> fromMetadata (AnnotationMetadata metadata ) {
210
210
return Arrays .stream (metadata .getInterfaceNames ()).map (it -> findType (it , type .getInterfaces ()));
211
211
}
212
212
@@ -220,20 +220,20 @@ private Stream<Class<?>> fromType() {
220
220
}
221
221
222
222
/**
223
- * Attempts to obtain {@link MethodsMetadata } from {@link Class}. Returns {@link Optional} containing
224
- * {@link MethodsMetadata } if metadata was read successfully, {@link Optional#empty()} otherwise.
223
+ * Attempts to obtain {@link AnnotationMetadata } from {@link Class}. Returns {@link Optional} containing
224
+ * {@link AnnotationMetadata } if metadata was read successfully, {@link Optional#empty()} otherwise.
225
225
*
226
226
* @param type must not be {@literal null}.
227
- * @return the optional {@link MethodsMetadata }.
227
+ * @return the optional {@link AnnotationMetadata }.
228
228
*/
229
- private static Optional <MethodsMetadata > getMetadata (Class <?> type ) {
229
+ private static Optional <AnnotationMetadata > getMetadata (Class <?> type ) {
230
230
231
231
try {
232
232
233
- var factory = new MethodsMetadataReaderFactory (type .getClassLoader ());
233
+ var factory = new SimpleMetadataReaderFactory (type .getClassLoader ());
234
234
var metadataReader = factory .getMetadataReader (ClassUtils .getQualifiedName (type ));
235
235
236
- return Optional .of (metadataReader .getMethodsMetadata ());
236
+ return Optional .of (metadataReader .getAnnotationMetadata ());
237
237
238
238
} catch (IOException e ) {
239
239
@@ -259,18 +259,18 @@ private static Class<?> findType(String name, Class<?>[] types) {
259
259
}
260
260
261
261
/**
262
- * Returns a {@link Map} containing method name to its positional index according to {@link MethodsMetadata }.
262
+ * Returns a {@link Map} containing method name to its positional index according to {@link AnnotationMetadata }.
263
263
*
264
264
* @param metadata
265
265
* @return
266
266
*/
267
- private static Map <String , Integer > getMethodOrder (MethodsMetadata metadata ) {
267
+ private static Map <String , Integer > getMethodOrder (AnnotationMetadata metadata ) {
268
268
269
- var methods = metadata .getMethods () //
269
+ var methods = metadata .getDeclaredMethods () //
270
270
.stream () //
271
271
.map (MethodMetadata ::getMethodName ) //
272
272
.distinct () //
273
- .collect ( Collectors . toList () );
273
+ .toList ();
274
274
275
275
return IntStream .range (0 , methods .size ()) //
276
276
.boxed () //
0 commit comments