Skip to content

Instantly share code, notes, and snippets.

@RealDeanZhao
Created March 22, 2017 07:08
Show Gist options
  • Select an option

  • Save RealDeanZhao/cb3cf3655a3b21b13136635d94335ed3 to your computer and use it in GitHub Desktop.

Select an option

Save RealDeanZhao/cb3cf3655a3b21b13136635d94335ed3 to your computer and use it in GitHub Desktop.
Deal with Optional using lambda
if (...) {
return redirectToAuthCodeUrl();
} else {
return Response.ok().build();
}
-->
return sessionToken
.filter(it -> ...)
.map(it -> Response.ok().build())
.orElse(redirectToAuthCodeUrl());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment