Skip to content

Instantly share code, notes, and snippets.

@jklingsporn
Created April 24, 2017 13:08
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 jklingsporn/ac1f479cff54fc12a0f1f46808b879ef to your computer and use it in GitHub Desktop.
Save jklingsporn/ac1f479cff54fc12a0f1f46808b879ef to your computer and use it in GitHub Desktop.
//fetch something from A to make a lookup on B
ADao adao = new ADao();
CompletableFuture<A> aFutureLoaded = adao.findByIdAsync(123);
BDao bdao = new BDao();
aFutureLoaded.thenCompose(
a->bdao.findBySomeAValueAsync(a.getSomeAValue());
).whenComplete((bResult,ex)->{
if(ex==null){
//do something with the result
}else{
//oops something went wrong
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment