public static < E > List < E > refineCandidates ( final List < E > candidates , final Predicate < ? super E > predicate ) { if ( candidates . size ( ) == 1 ) { return candidates ; } List < E > newCandidates = CollectionUtils . filter ( candidates , predicate ) ; if ( newCandidates . isEmpty ( ) ) { return candidates ; } return newCandidates ; }
Refines a list of candidate objects based on a inclusion predicate . If no candidates are found the original list will be retained in the result . Therefore the result will always have 1 or more elements in it .