Skip to content

Instantly share code, notes, and snippets.

@pcholt
Created November 15, 2017 22:19
Show Gist options
  • Save pcholt/db7e4f3367142fd01c8d2b9f3d05220f to your computer and use it in GitHub Desktop.
Save pcholt/db7e4f3367142fd01c8d2b9f3d05220f to your computer and use it in GitHub Desktop.
Join strings, but first filter each on a predicate
return StringUtils.join( Stream.of(
customerDetails.getPersonalName(),
customerDetails.getMiddleName(),
customerDetails.getFamilyName() ).filter( Objects::nonNull ).iterator(), " ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment