private Collection < String > getPreferredConnections ( ModeledAuthenticatedUser user , Collection < String > identifiers ) { // Search provided identifiers for any preferred connections for ( String identifier : identifiers ) { // If at least one prefferred connection is found, assume it is the // only preferred connection if ( user . isPreferredConnection ( identifier ) ) return Collections . singletonList ( identifier ) ; } // No preferred connections were found return identifiers ; }
Filters the given collection of connection identifiers returning a new collection which contains only those identifiers which are preferred . If no connection identifiers within the given collection are preferred the collection is left untouched .