2929
3030import org .apache .commons .logging .Log ;
3131import org .apache .commons .logging .LogFactory ;
32-
3332import org .springframework .beans .BeanUtils ;
3433import org .springframework .core .log .LogMessage ;
3534import org .springframework .core .type .AnnotationMetadata ;
@@ -159,7 +158,7 @@ private Stream<PropertyDescriptor> collectDescriptors() {
159158 Stream <PropertyDescriptor > allButDefaultGetters = Arrays .stream (BeanUtils .getPropertyDescriptors (type )) //
160159 .filter (it -> !hasDefaultGetter (it ));
161160
162- Stream <PropertyDescriptor > ownDescriptors = metadata .map (it -> filterAndOrder (allButDefaultGetters , it ))
161+ Stream <PropertyDescriptor > ownDescriptors = metadata .map (it -> filterAndOrder (allButDefaultGetters , it )) //
163162 .orElse (allButDefaultGetters );
164163
165164 Stream <PropertyDescriptor > superTypeDescriptors = metadata .map (this ::fromMetadata ) //
@@ -177,18 +176,17 @@ private Stream<PropertyDescriptor> collectDescriptors() {
177176 * @param metadata must not be {@literal null}.
178177 * @return
179178 */
180- private static Stream <PropertyDescriptor > filterAndOrder (Stream <PropertyDescriptor > source ,
179+ private Stream <PropertyDescriptor > filterAndOrder (Stream <PropertyDescriptor > source ,
181180 AnnotationMetadata metadata ) {
182181
183182 Map <String , Integer > orderedMethods = getMethodOrder (metadata );
184183
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 ));
188186
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 ())));
192190 }
193191
194192 /**
@@ -228,7 +226,8 @@ private static Optional<AnnotationMetadata> getMetadata(Class<?> type) {
228226
229227 } catch (IOException e ) {
230228
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 ));
232231 return Optional .empty ();
233232 }
234233 }
0 commit comments