@@ -1439,27 +1439,29 @@ public static Stream<Method> streamMethods(Class<?> clazz, Predicate<Method> pre
1439
1439
Preconditions .notNull (predicate , "Predicate must not be null" );
1440
1440
Preconditions .notNull (traversalMode , "HierarchyTraversalMode must not be null" );
1441
1441
1442
- return findAllMethodsInHierarchy (clazz , predicate , traversalMode ).stream ().distinct ();
1442
+ // @formatter:off
1443
+ return findAllMethodsInHierarchy (clazz , traversalMode ).stream ()
1444
+ .filter (predicate )
1445
+ .distinct ();
1446
+ // @formatter:on
1443
1447
}
1444
1448
1445
1449
/**
1446
1450
* Find all non-synthetic methods in the superclass and interface hierarchy,
1447
- * excluding Object, that match the specified {@code predicate} .
1451
+ * excluding Object.
1448
1452
*/
1449
- private static List <Method > findAllMethodsInHierarchy (Class <?> clazz , Predicate <Method > predicate ,
1450
- HierarchyTraversalMode traversalMode ) {
1451
-
1453
+ private static List <Method > findAllMethodsInHierarchy (Class <?> clazz , HierarchyTraversalMode traversalMode ) {
1452
1454
Preconditions .notNull (clazz , "Class must not be null" );
1453
1455
Preconditions .notNull (traversalMode , "HierarchyTraversalMode must not be null" );
1454
1456
1455
1457
// @formatter:off
1456
1458
List <Method > localMethods = getDeclaredMethods (clazz , traversalMode ).stream ()
1457
- .filter (predicate . and ( method -> !method .isSynthetic () ))
1459
+ .filter (method -> !method .isSynthetic ())
1458
1460
.collect (toList ());
1459
- List <Method > superclassMethods = getSuperclassMethods (clazz , predicate , traversalMode ).stream ()
1461
+ List <Method > superclassMethods = getSuperclassMethods (clazz , traversalMode ).stream ()
1460
1462
.filter (method -> !isMethodShadowedByLocalMethods (method , localMethods ))
1461
1463
.collect (toList ());
1462
- List <Method > interfaceMethods = getInterfaceMethods (clazz , predicate , traversalMode ).stream ()
1464
+ List <Method > interfaceMethods = getInterfaceMethods (clazz , traversalMode ).stream ()
1463
1465
.filter (method -> !isMethodShadowedByLocalMethods (method , localMethods ))
1464
1466
.collect (toList ());
1465
1467
// @formatter:on
@@ -1595,18 +1597,16 @@ private static int defaultMethodSorter(Method method1, Method method2) {
1595
1597
return comparison ;
1596
1598
}
1597
1599
1598
- private static List <Method > getInterfaceMethods (Class <?> clazz , Predicate <Method > predicate ,
1599
- HierarchyTraversalMode traversalMode ) {
1600
-
1600
+ private static List <Method > getInterfaceMethods (Class <?> clazz , HierarchyTraversalMode traversalMode ) {
1601
1601
List <Method > allInterfaceMethods = new ArrayList <>();
1602
1602
for (Class <?> ifc : clazz .getInterfaces ()) {
1603
1603
1604
1604
// @formatter:off
1605
1605
List <Method > localInterfaceMethods = getMethods (ifc ).stream ()
1606
- .filter (predicate . and ( method -> !isAbstract (method ) ))
1606
+ .filter (m -> !isAbstract (m ))
1607
1607
.collect (toList ());
1608
1608
1609
- List <Method > superinterfaceMethods = getInterfaceMethods (ifc , predicate , traversalMode ).stream ()
1609
+ List <Method > superinterfaceMethods = getInterfaceMethods (ifc , traversalMode ).stream ()
1610
1610
.filter (method -> !isMethodShadowedByLocalMethods (method , localInterfaceMethods ))
1611
1611
.collect (toList ());
1612
1612
// @formatter:on
@@ -1656,14 +1656,12 @@ private static boolean isFieldShadowedByLocalFields(Field field, List<Field> loc
1656
1656
return localFields .stream ().anyMatch (local -> local .getName ().equals (field .getName ()));
1657
1657
}
1658
1658
1659
- private static List <Method > getSuperclassMethods (Class <?> clazz , Predicate <Method > predicate ,
1660
- HierarchyTraversalMode traversalMode ) {
1661
-
1659
+ private static List <Method > getSuperclassMethods (Class <?> clazz , HierarchyTraversalMode traversalMode ) {
1662
1660
Class <?> superclass = clazz .getSuperclass ();
1663
1661
if (!isSearchable (superclass )) {
1664
1662
return Collections .emptyList ();
1665
1663
}
1666
- return findAllMethodsInHierarchy (superclass , predicate , traversalMode );
1664
+ return findAllMethodsInHierarchy (superclass , traversalMode );
1667
1665
}
1668
1666
1669
1667
private static boolean isMethodShadowedByLocalMethods (Method method , List <Method > localMethods ) {
0 commit comments