Skip to content

Instantly share code, notes, and snippets.

@damgel
Created August 8, 2017 19:43
Show Gist options
  • Save damgel/dcee6d7671e28b4953c8de957bc2ba7a to your computer and use it in GitHub Desktop.
Save damgel/dcee6d7671e28b4953c8de957bc2ba7a to your computer and use it in GitHub Desktop.
Optional<BigDecimal> max = Optional.empty();
if (!this.itemsFiltered.isEmpty()) {//check if list is not empty
max = itemsFiltered.stream()
.map(a -> a.getPrecioVentaNuevo())
.max(Comparator.naturalOrder());
if (max.isPresent()) {
Utilidades.Error("maxOptional:" + max);//prints optional value
Utilidades.Error("maxValue:" + max.get());//prints real value if any found.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment