optional throw exception if present code example
Example 1: optional throw if present
Optional.of(usuarios.findByEmail(usuario.getEmail())).ifPresent(param -> {
throw new IllegalArgumentException("Only Strings allowed in path parameters.")
});
Example 2: stream optional if present anymatch
List<Optional<String>> listOfOptionals = Arrays.asList(
Optional.empty(), Optional.of("foo"), Optional.empty(), Optional.of("bar"));