You can do this in Java 8 (but it might be a bit h...
# getting-started
m
You can do this in Java 8 (but it might be a bit hard to read):
Copy code
return Optional.ofNullable(req.cookies)
               .flatmap(::extractFromCookie)
               .map(Optional::of)
               .orElseGet {
                    Optional.ofNullable(req.header)
                            .flatMap(::extractFromHeader)
               }
❤️ 1