private static Set < Credential > sanitizeCredentials ( final Credential [ ] credentials ) { if ( credentials != null && credentials . length > 0 ) { return Arrays . stream ( credentials ) . filter ( Objects :: nonNull ) . collect ( Collectors . toCollection ( LinkedHashSet :: new ) ) ; } return new HashSet <> ( 0 ) ; }
Sanitize credentials set . It s important to keep the order of the credentials in the final set as they were presented .