add interface generation
diff --git a/lib/java/gradle/generateTestThrift.gradle b/lib/java/gradle/generateTestThrift.gradle
index 924dd0d..d5bc3af 100644
--- a/lib/java/gradle/generateTestThrift.gradle
+++ b/lib/java/gradle/generateTestThrift.gradle
@@ -91,7 +91,7 @@
ext.outputBuffer = new ByteArrayOutputStream()
- thriftCompile(it, 'JavaBeansTest.thrift', 'java:beans,nocamel', genBeanSrc)
+ thriftCompile(it, 'JavaBeansTest.thrift', 'java:beans,nocamel,future_iface', genBeanSrc)
}
task generateReuseJava(group: 'Build') {
@@ -100,7 +100,7 @@
ext.outputBuffer = new ByteArrayOutputStream()
- thriftCompile(it, 'FullCamelTest.thrift', 'java:fullcamel', genFullCamelSrc)
+ thriftCompile(it, 'FullCamelTest.thrift', 'java:fullcamel,future_iface', genFullCamelSrc)
}
task generateFullCamelJava(group: 'Build') {
diff --git a/lib/java/src/org/apache/thrift/async/AsyncMethodFutureAdapter.java b/lib/java/src/org/apache/thrift/async/AsyncMethodFutureAdapter.java
new file mode 100644
index 0000000..0bee3a7
--- /dev/null
+++ b/lib/java/src/org/apache/thrift/async/AsyncMethodFutureAdapter.java
@@ -0,0 +1,35 @@
+package org.apache.thrift.async;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * A simple adapter that bridges {@link AsyncMethodCallback} with {@link CompletableFuture}-returning style clients.
+ * Compiler generated code will invoke this adapter to implement {@code FutureClient}s.
+ *
+ * @param <T> return type (can be {@link Void}).
+ */
+public final class AsyncMethodFutureAdapter<T> implements AsyncMethodCallback<T> {
+
+ private AsyncMethodFutureAdapter() {
+ }
+
+ public static <T> AsyncMethodFutureAdapter<T> create() {
+ return new AsyncMethodFutureAdapter<>();
+ }
+
+ private final CompletableFuture<T> future = new CompletableFuture<>();
+
+ public CompletableFuture<T> getFuture() {
+ return future;
+ }
+
+ @Override
+ public void onComplete(T response) {
+ future.complete(response);
+ }
+
+ @Override
+ public void onError(Exception exception) {
+ future.completeExceptionally(exception);
+ }
+}