java - CompletableFuture 和 handle() 方法向后移植到 Java7
问题描述
我有一个用 Java 8 编写的代码,使用 CompletableFuture 和 handle 方法:
public interface Move
{
CompletableFuture<Boolean> move(float i);
}
然后我们创建一个 move 的 instance mover 并调用:
mover.move(i).handle(new BiFunction<Boolean, Throwable, Object>()
{
public Object apply(Boolean b, Throwable err)
{
return something; //Didn't want to overwhelm the code here; in the original one a method is called
}
}
应该如何使其向后兼容Java7?或者我应该如何解决这个问题?
解决方案
推荐阅读
- javascript - 测试选择元素与 Jest 反应
- javascript - 使用jquery捕获Bootstrap Modal中动态按钮的点击事件
- botframework - 退出事件/欢迎事件未触发
- python - Flask 静态文件内容类型是重定向后的 text/html
- material-ui - react-dom.development.js?61bb:530 警告:道具类名不匹配
- android - 运行 ./gradlew bundleRelease 不会在 react-native 中生成发布 aab
- sql - 如何在 sql 查询中进行采样以使用 pandas 获取数据帧
- html - 将登录按钮降低到我的网络应用程序的最底部
- keras - Keras LSTM 转换为 Core ML 导致不同形状的输入层
- python - 运行 Markovify 项目时出现 PyCharm 错误