Skip to content

Instantly share code, notes, and snippets.

@ariesmcrae
Last active December 9, 2019 12:00
Show Gist options
  • Save ariesmcrae/734739b132e045d3e549753f6d93affb to your computer and use it in GitHub Desktop.
Save ariesmcrae/734739b132e045d3e549753f6d93affb to your computer and use it in GitHub Desktop.
Java: Find string in List of strings
private static boolean isStringInputInTheList(String input, List<String> list) {
return Optional.ofNullable(list)
.map(Collection::parallelStream)
.orElseGet(Stream::empty)
.anyMatch(x -> StringUtils.isNotBlank(input) && x.equals(input));
}
// where:
// StringUtils is the org.apache.commons.lang3.StringUtils
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment