I am trying to write one-liner code that will return false if any of the values in the map is empty string or string of blanks. Thoughts?
Something like a advanced version of:
Optional.ofNullable(map).filter(s -> s.isEmpty());
using your current approach:
boolean present =
Optional.ofNullable(map)
.filter(x ->
x.values().stream()
.noneMatch(s -> s != null && s.trim().isEmpty()))
.isPresent();
or simply:
boolean present = map != null &&
map.values()
.stream()
.noneMatch(s -> s != null && s.trim().isEmpty());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With