Java异步返回CompletableFuture

Java异步返回CompletableFuture,java,asynchronous,completable-future,consumer,Java,Asynchronous,Completable Future,Consumer,如果我们有AsyncResponse-response变量,我们可以编写如下代码: CompletableFuture#然后接受(回复:resume) 我不明白如何将boolean resume(Object response)方法从AsyncResponse类传递到thenacept(),该方法以Consumer为参数,因为Consumer返回void方法引用将忽略返回值。如果将方法引用扩展到匿名内部类中,它将如下所示: completableFuture.thenAccept(new Con

如果我们有
AsyncResponse-response
变量,我们可以编写如下代码:
CompletableFuture#然后接受(回复:resume)


我不明白如何将
boolean resume(Object response)
方法从
AsyncResponse
类传递到
thenacept()
,该方法以
Consumer
为参数,因为
Consumer
返回
void

方法引用将忽略返回值。如果将方法引用扩展到匿名内部类中,它将如下所示:

completableFuture.thenAccept(new Consumer<Object>() {
        @Override
        public void accept(Object object) {
            response.resume(object);
        }
    });

completableFuture.thenAccept(新消费者(){
@凌驾
公共无效接受(对象){
回复。简历(对象);
}
});

可以尝试使用thenApply(…)?“我们如何传递…”-忽略返回值。
completableFuture.thenapport(response::resume)就足够了。