@ SuppressWarnings ( "unchecked" ) public static < T > Stream < Class < ? extends T > > streamClasses ( Collection < Class < ? > > classes , Class < ? extends T > baseClass ) { return classes . stream ( ) . filter ( ClassPredicates . classIsDescendantOf ( baseClass ) ) . map ( c -> ( Class < T > ) c ) ; }
Checks that classes satisfying a specification are assignable to a base class and return a typed stream of it .