Skip to content

Instantly share code, notes, and snippets.

@zivce
Created April 17, 2021 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zivce/e7b075a8d21b83454a4bbd92b8c288c3 to your computer and use it in GitHub Desktop.
Save zivce/e7b075a8d21b83454a4bbd92b8c288c3 to your computer and use it in GitHub Desktop.
getValue(x).orElse(getValue(y)
.orElseThrow(() -> new NotFoundException("value not present")));
public Optional<Value> getValue(Source s)
{
System.out.println("Source: " + s.getName());
// returns value from s source
}
// when getValue(x) is present system will output
Source: x
Source: y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment