29
29
30
30
import org .apache .commons .logging .Log ;
31
31
import org .apache .commons .logging .LogFactory ;
32
-
33
32
import org .springframework .beans .BeanUtils ;
34
33
import org .springframework .core .log .LogMessage ;
35
34
import org .springframework .core .type .AnnotationMetadata ;
@@ -159,7 +158,7 @@ private Stream<PropertyDescriptor> collectDescriptors() {
159
158
Stream <PropertyDescriptor > allButDefaultGetters = Arrays .stream (BeanUtils .getPropertyDescriptors (type )) //
160
159
.filter (it -> !hasDefaultGetter (it ));
161
160
162
- Stream <PropertyDescriptor > ownDescriptors = metadata .map (it -> filterAndOrder (allButDefaultGetters , it ))
161
+ Stream <PropertyDescriptor > ownDescriptors = metadata .map (it -> filterAndOrder (allButDefaultGetters , it )) //
163
162
.orElse (allButDefaultGetters );
164
163
165
164
Stream <PropertyDescriptor > superTypeDescriptors = metadata .map (this ::fromMetadata ) //
@@ -177,18 +176,17 @@ private Stream<PropertyDescriptor> collectDescriptors() {
177
176
* @param metadata must not be {@literal null}.
178
177
* @return
179
178
*/
180
- private static Stream <PropertyDescriptor > filterAndOrder (Stream <PropertyDescriptor > source ,
179
+ private Stream <PropertyDescriptor > filterAndOrder (Stream <PropertyDescriptor > source ,
181
180
AnnotationMetadata metadata ) {
182
181
183
182
Map <String , Integer > orderedMethods = getMethodOrder (metadata );
184
183
185
- if (orderedMethods .isEmpty ()) {
186
- return source ;
187
- }
184
+ Stream <PropertyDescriptor > filtered = source .filter (it -> it .getReadMethod () != null )
185
+ .filter (it -> it .getReadMethod ().getDeclaringClass ().equals (type ));
188
186
189
- return source . filter ( descriptor -> descriptor . getReadMethod () != null )
190
- . filter ( descriptor -> orderedMethods . containsKey ( descriptor . getReadMethod (). getName ()))
191
- .sorted (Comparator .comparingInt (left -> orderedMethods .get (left .getReadMethod ().getName ())));
187
+ return orderedMethods . isEmpty ( )
188
+ ? filtered
189
+ : filtered .sorted (Comparator .comparingInt (left -> orderedMethods .get (left .getReadMethod ().getName ())));
192
190
}
193
191
194
192
/**
@@ -228,7 +226,8 @@ private static Optional<AnnotationMetadata> getMetadata(Class<?> type) {
228
226
229
227
} catch (IOException e ) {
230
228
231
- logger .info (LogMessage .format ("Couldn't read class metadata for %s. Input property calculation might fail" , type ));
229
+ logger .info (
230
+ LogMessage .format ("Couldn't read class metadata for %s. Input property calculation might fail" , type ));
232
231
return Optional .empty ();
233
232
}
234
233
}
0 commit comments