Skip to content

Instantly share code, notes, and snippets.

@Dalamar42
Created September 7, 2016 10:01
Show Gist options
  • Save Dalamar42/dc7f694f0c66fa2de9f39615864cc8f0 to your computer and use it in GitHub Desktop.
Save Dalamar42/dc7f694f0c66fa2de9f39615864cc8f0 to your computer and use it in GitHub Desktop.
String output = "value";
ListenableFuture<String> future = Futures.immediateFuture(output);
ListenableFuture<String> firstTransformedFuture = Futures.transform(
future, (Function<String, String>) value -> value + "_a"
);
ListenableFuture<String> secondTransformedFuture = Futures.transform(
firstTransformedFuture, (Function<String, String>) value -> value + "_b"
);
String transformedOutput = secondTransformedFuture.get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment