I have a bit of an odd situation that doesn’t seem to allow this peg to fit into any of the widely established CompletableFuture holes.
- Within a primary method that is evaluating returned booleans, I am wanting to allow calls to three different methods to complete asynchronously. Each of these three methods can return either a TRUE or a FALSE.
- If any return a FALSE, I want the evaluation to drop the remainder and simply return that FALSE value. The point being, it can be any of the three, not necessarily the first.
- But most importantly, I need the evaluation to wait until all three return TRUE before actually returning TRUE. This is critically important.
Right now, I am using a basic &&
chain to make this evaluation:
public boolean evaluateChecks() {
return checkOne().Join() && checkTwo().Join() && checkThree().Join();
}
However this still does things in a specific order - if checkThree()
is the first to return a FALSE value, it still has to wait until the prior two have provided their values before it gets evaluated, due to how the &&
fall-through works.
Right now all three methods return CompletableFuture<Boolean>
, but I have no problem reverting these back into normal methods in order to run a CompletableFuture
in the primary method that evaluates them.
I have looked at quite a few examples, but none seem to provide me with the functionality I need.