public class NestedTransformableFutureIgnoringReturn extends Object implements TransformableFuture<Void>
| Constructor and Description |
|---|
NestedTransformableFutureIgnoringReturn(TransformableFuture<TransformableFuture<?>> nestedFuture) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
Void |
get() |
Void |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
<V> TransformableFuture<V> |
transformAsync(FutureTransform<Void,TransformableFuture<V>> futureTransform)
Creates a new
Future which is backed by the Future returned from the provided
futureTransform function. |
TransformableFuture<Void> |
transformAsyncIgnoringReturn(FutureTransform<Void,TransformableFuture<?>> futureTransform)
Like
TransformableFuture.transformAsync(FutureTransform), except useful in cases where you intentionally
do not care about the result value contained in the transform functions returned
Future. |
<V> TransformableFuture<V> |
transformSync(FutureTransform<Void,V> futureTransform)
Creates a new
Future which is completed immediately when this Future
completes, with a value that is the result of applying the provided futureTransform
function to this Future's result. |
TransformableFuture<Void> |
whenDoneOrCancelled(FutureDoneCallback callback)
Because the result in this context is the result of a nested future, and "done" implies
having a result, we put off calling the callbacks until the nested future is done to
coincide with when this future has a result.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitimmediate, immediateFailedpublic NestedTransformableFutureIgnoringReturn(TransformableFuture<TransformableFuture<?>> nestedFuture)
public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled in interface Future<Void>public Void get() throws InterruptedException, ExecutionException
get in interface Future<Void>InterruptedExceptionExecutionExceptionpublic Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get in interface Future<Void>InterruptedExceptionExecutionExceptionTimeoutExceptionpublic <V> TransformableFuture<V> transformSync(FutureTransform<Void,V> futureTransform)
TransformableFutureFuture which is completed immediately when this Future
completes, with a value that is the result of applying the provided futureTransform
function to this Future's result.
Terminology inspired by Guava's Futures extensions.
transformSync in interface TransformableFuture<Void>V - The type of new result.futureTransform - Function which accepts the result from this future and returns a new
result or throws an exception if a result cannot be computed. This new
result is what will be returned from the returned Future.public <V> TransformableFuture<V> transformAsync(FutureTransform<Void,TransformableFuture<V>> futureTransform)
TransformableFutureFuture which is backed by the Future returned from the provided
futureTransform function.
Use this when you need to add a callback on an existing TransformableFuture which
returns yet another Future, chaining several asynchronous actions together into one
final result Future. If you just used TransformableFuture.transformSync(FutureTransform) you'd
end up with a Future<Future<U>> (a future who's result is another future) which is
difficult to work with. By using this API, the result Future is "unwrapped" and you
get a more intuitive Future<U> to work with.
Terminology inspired by Guava's
Futures
extensions such as AsyncFunction.
transformAsync in interface TransformableFuture<Void>V - The type of the result within the returned Future of the transform
function.futureTransform - Function which accepts the result from this future and returns either
a new Future or null.public TransformableFuture<Void> transformAsyncIgnoringReturn(FutureTransform<Void,TransformableFuture<?>> futureTransform)
TransformableFutureTransformableFuture.transformAsync(FutureTransform), except useful in cases where you intentionally
do not care about the result value contained in the transform functions returned
Future.
APIs like Message.process() may intentionally require the parameterized type of
Future<Void> to clearly document that both the result of the Future is unused
(we only care if it succeeded or not) and to prevent an implementor from accidentally
returning a Future<Future> which would never have its result Future examined
because the consumer is ignoring the return value. This would definitely be a bug.
transformAsyncIgnoringReturn in interface TransformableFuture<Void>public TransformableFuture<Void> whenDoneOrCancelled(FutureDoneCallback callback)
whenDoneOrCancelled in interface TransformableFuture<Void>Copyright © 2016. All rights reserved.