Skip to content

Instantly share code, notes, and snippets.

@nachivpn
Last active July 30, 2017 18:28
Show Gist options
  • Save nachivpn/b2cd15fa5105898bbb33a0f007f4ca59 to your computer and use it in GitHub Desktop.
Save nachivpn/b2cd15fa5105898bbb33a0f007f4ca59 to your computer and use it in GitHub Desktop.
EitherPatternMatching
//return a printable string containing component details, exception if component is unavailable
public String print(Either<Exception, Component> componentResp){
return componentResp.match(
(Exception ex) -> "Failed because " + ex.getMessage(),
(Component p) -> "Component info: " + p.prettyResult());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment