CompletableFuture<Boolean>> decision; private final Node onTrue; private final Node onFalse; @Override public CompletableFuture<Response> apply(Resource resource, Request request) { return decision .apply(resource, request) .thenCompose(decisionResult -> decisionResult ? onTrue.apply(resource, request) : onFalse.apply(resource, request)); } public static interface Fn extends BiFunction<Resource, Request,CompletableFuture<Boolean>> { } }