If you're using Java 9, you can do something like ...
# getting-started
m
If you're using Java 9, you can do something like this:
Copy code
return Optional.ofNullable(req.cookies)
               .flatmap(::extractFromCookie)
               .or {
                   Optional.ofNullable(req.header)
                           .flatMap(::extractFromHeader)
               }
The
or
method is new in Java 9.