@@ -1490,27 +1490,29 @@ public static Stream<Method> streamMethods(Class<?> clazz, Predicate<Method> pre
1490
1490
Preconditions .notNull (predicate , "Predicate must not be null" );
1491
1491
Preconditions .notNull (traversalMode , "HierarchyTraversalMode must not be null" );
1492
1492
1493
- return findAllMethodsInHierarchy (clazz , predicate , traversalMode ).stream ().distinct ();
1493
+ // @formatter:off
1494
+ return findAllMethodsInHierarchy (clazz , traversalMode ).stream ()
1495
+ .filter (predicate )
1496
+ .distinct ();
1497
+ // @formatter:on
1494
1498
}
1495
1499
1496
1500
/**
1497
1501
* Find all non-synthetic methods in the superclass and interface hierarchy,
1498
- * excluding Object, that match the specified {@code predicate} .
1502
+ * excluding Object.
1499
1503
*/
1500
- private static List <Method > findAllMethodsInHierarchy (Class <?> clazz , Predicate <Method > predicate ,
1501
- HierarchyTraversalMode traversalMode ) {
1502
-
1504
+ private static List <Method > findAllMethodsInHierarchy (Class <?> clazz , HierarchyTraversalMode traversalMode ) {
1503
1505
Preconditions .notNull (clazz , "Class must not be null" );
1504
1506
Preconditions .notNull (traversalMode , "HierarchyTraversalMode must not be null" );
1505
1507
1506
1508
// @formatter:off
1507
1509
List <Method > localMethods = getDeclaredMethods (clazz , traversalMode ).stream ()
1508
- .filter (predicate . and ( method -> !method .isSynthetic () ))
1510
+ .filter (method -> !method .isSynthetic ())
1509
1511
.collect (toList ());
1510
- List <Method > superclassMethods = getSuperclassMethods (clazz , predicate , traversalMode ).stream ()
1512
+ List <Method > superclassMethods = getSuperclassMethods (clazz , traversalMode ).stream ()
1511
1513
.filter (method -> !isMethodShadowedByLocalMethods (method , localMethods ))
1512
1514
.collect (toList ());
1513
- List <Method > interfaceMethods = getInterfaceMethods (clazz , predicate , traversalMode ).stream ()
1515
+ List <Method > interfaceMethods = getInterfaceMethods (clazz , traversalMode ).stream ()
1514
1516
.filter (method -> !isMethodShadowedByLocalMethods (method , localMethods ))
1515
1517
.collect (toList ());
1516
1518
// @formatter:on
@@ -1646,18 +1648,16 @@ private static int defaultMethodSorter(Method method1, Method method2) {
1646
1648
return comparison ;
1647
1649
}
1648
1650
1649
- private static List <Method > getInterfaceMethods (Class <?> clazz , Predicate <Method > predicate ,
1650
- HierarchyTraversalMode traversalMode ) {
1651
-
1651
+ private static List <Method > getInterfaceMethods (Class <?> clazz , HierarchyTraversalMode traversalMode ) {
1652
1652
List <Method > allInterfaceMethods = new ArrayList <>();
1653
1653
for (Class <?> ifc : clazz .getInterfaces ()) {
1654
1654
1655
1655
// @formatter:off
1656
1656
List <Method > localInterfaceMethods = getMethods (ifc ).stream ()
1657
- .filter (predicate . and ( method -> !isAbstract (method ) ))
1657
+ .filter (m -> !isAbstract (m ))
1658
1658
.collect (toList ());
1659
1659
1660
- List <Method > superinterfaceMethods = getInterfaceMethods (ifc , predicate , traversalMode ).stream ()
1660
+ List <Method > superinterfaceMethods = getInterfaceMethods (ifc , traversalMode ).stream ()
1661
1661
.filter (method -> !isMethodShadowedByLocalMethods (method , localInterfaceMethods ))
1662
1662
.collect (toList ());
1663
1663
// @formatter:on
@@ -1707,14 +1707,12 @@ private static boolean isFieldShadowedByLocalFields(Field field, List<Field> loc
1707
1707
return localFields .stream ().anyMatch (local -> local .getName ().equals (field .getName ()));
1708
1708
}
1709
1709
1710
- private static List <Method > getSuperclassMethods (Class <?> clazz , Predicate <Method > predicate ,
1711
- HierarchyTraversalMode traversalMode ) {
1712
-
1710
+ private static List <Method > getSuperclassMethods (Class <?> clazz , HierarchyTraversalMode traversalMode ) {
1713
1711
Class <?> superclass = clazz .getSuperclass ();
1714
1712
if (!isSearchable (superclass )) {
1715
1713
return Collections .emptyList ();
1716
1714
}
1717
- return findAllMethodsInHierarchy (superclass , predicate , traversalMode );
1715
+ return findAllMethodsInHierarchy (superclass , traversalMode );
1718
1716
}
1719
1717
1720
1718
private static boolean isMethodShadowedByLocalMethods (Method method , List <Method > localMethods ) {
0 commit comments