public static < T > List < T > filter ( Collection < T > items , Predicate < T > predicate ) { List < T > result = new ArrayList <> ( ) ; if ( ! isEmpty ( items ) ) { for ( T item : items ) { if ( predicate . apply ( item ) ) { result . add ( item ) ; } } } return result ; }
Filters a collection using the given predicate .