/** * Filters the elements of an Enumerable based on a * specified type. * * <p>Analogous to LINQ's Enumerable.OfType extension method.</p> * * @param clazz Target type * @param <TResult> Target type * * @return Collection of T2 */ public static <TSource, TResult> Enumerable<TResult> ofType( Enumerable<TSource> enumerable, Class<TResult> clazz) { //noinspection unchecked return (Enumerable) where(enumerable, Functions.ofTypePredicate(clazz)); }