@ SuppressWarnings ( "unchecked" ) public final Collection < T > filter ( final Collection < T > c ) { if ( getRules ( ) != null && getRules ( ) . length > 0 ) { // attempt to use the same concrete collection type // as is passed in.. Collection < T > filtered ; try { filtered = c . getClass ( ) . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { filtered = new ArrayList < T > ( ) ; } if ( type == MATCH_ALL ) { filtered . addAll ( matchAll ( c ) ) ; } else { filtered . addAll ( matchAny ( c ) ) ; } return filtered ; } return c ; }
Filter the given collection into a new collection .