T
- type of the future's resultpublic interface Future<T>
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
Tries to cancel the future's operation.
|
<R> Future<R> |
exceptionally(ApplyFunction<Throwable,? extends R> exceptionallyFunction)
Applies the given function to the value of the future if the future has been completed
exceptionally.
|
<R> Future<R> |
exceptionallyAsync(ApplyFunction<Throwable,? extends R> exceptionallyFunction,
Executor executor)
Applies the given function to the value of the future if the future has been completed
exceptionally.
|
T |
get()
Gets the result value of the future.
|
T |
get(long timeout,
TimeUnit unit)
Gets the result value of the future.
|
T |
getNow(T valueIfAbsent)
Gets the value of the future.
|
<R> Future<R> |
handle(BiFunction<? super T,Throwable,? extends R> biFunction)
Applies the given handle function to the result of the future.
|
<R> Future<R> |
handleAsync(BiFunction<? super T,Throwable,? extends R> biFunction,
Executor executor)
Applies the given handle function to the result of the future.
|
boolean |
isDone()
Checks if the future has been completed.
|
Future<Void> |
thenAccept(AcceptFunction<? super T> acceptFunction)
Applies the accept function to the value of the future.
|
Future<Void> |
thenAcceptAsync(AcceptFunction<? super T> acceptFunction,
Executor executor)
Applies the accept function to the value of the future.
|
<R> Future<R> |
thenApply(ApplyFunction<? super T,? extends R> applyFunction)
Applies the given function to the value of the future.
|
<R> Future<R> |
thenApplyAsync(ApplyFunction<? super T,? extends R> applyFunction,
Executor executor)
Applies the given function to the value of the future.
|
<U,R> Future<R> |
thenCombine(Future<U> other,
BiFunction<? super T,? super U,? extends R> biFunction)
Applies the given function to the result of this and the other future after both futures
have completed.
|
<U,R> Future<R> |
thenCombineAsync(Future<U> other,
BiFunction<? super T,? super U,? extends R> biFunction,
Executor executor)
Applies the given function to the result of this and the other future after both futures
have completed.
|
<R> Future<R> |
thenCompose(ApplyFunction<? super T,? extends Future<R>> composeFunction)
Applies the given function to the value of the future.
|
<R> Future<R> |
thenComposeAsync(ApplyFunction<? super T,? extends Future<R>> composeFunction,
Executor executor)
Applies the given function to the value of the future.
|
boolean isDone()
boolean cancel(boolean mayInterruptIfRunning)
mayInterruptIfRunning
- true iff the future operation may be interruptedT get() throws InterruptedException, ExecutionException
CancellationException
- if the future has been cancelledInterruptedException
- if the current thread was interrupted while waiting for the resultExecutionException
- if the future has been completed with an exceptionT get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
TimeoutException
.timeout
- the time to wait for the future to be doneunit
- time unit for the timeout argumentCancellationException
- if the future has been cancelledInterruptedException
- if the current thread was interrupted while waiting for the resultExecutionException
- if the future has been completed with an exceptionTimeoutException
- if the future has not been completed within the given timeoutT getNow(T valueIfAbsent) throws ExecutionException
valueIfAbsent
- value which is returned if the future has not been completedExecutionException
- if the future has been completed with an exception<R> Future<R> thenApplyAsync(ApplyFunction<? super T,? extends R> applyFunction, Executor executor)
The apply function is executed asynchronously by the given executor.
R
- type of the apply function's return valueapplyFunction
- function to apply to the future's valueexecutor
- used to execute the given apply function asynchronously<R> Future<R> thenApply(ApplyFunction<? super T,? extends R> applyFunction)
R
- type of the apply function's return valueapplyFunction
- function to apply to the future's valueFuture<Void> thenAcceptAsync(AcceptFunction<? super T> acceptFunction, Executor executor)
ApplyFunction
, the
AcceptFunction
does not return a value. The returned future, thus, represents only
the completion of the accept callback.
The accept function is executed asynchronously by the given executor.
acceptFunction
- function to apply to the future's valueexecutor
- used to execute the given apply function asynchronouslyFuture<Void> thenAccept(AcceptFunction<? super T> acceptFunction)
ApplyFunction
, the
AcceptFunction
does not return a value. The returned future, thus, represents only
the completion of the accept callback.acceptFunction
- function to apply to the future's value<R> Future<R> exceptionallyAsync(ApplyFunction<Throwable,? extends R> exceptionallyFunction, Executor executor)
The apply function is executed asynchronously by the given executor.
R
- type of the apply function's return valueexceptionallyFunction
- to apply to the future's value if it is an exceptionexecutor
- used to execute the given apply function asynchronously<R> Future<R> exceptionally(ApplyFunction<Throwable,? extends R> exceptionallyFunction)
R
- type of the apply function's return valueexceptionallyFunction
- to apply to the future's value if it is an exception<R> Future<R> thenComposeAsync(ApplyFunction<? super T,? extends Future<R>> composeFunction, Executor executor)
The apply function is executed asynchronously by the given executor.
R
- type of the returned future's valuecomposeFunction
- to apply to the future's value. The function returns a future which is
flattenedexecutor
- used to execute the given apply function asynchronously<R> Future<R> thenCompose(ApplyFunction<? super T,? extends Future<R>> composeFunction)
R
- type of the returned future's valuecomposeFunction
- to apply to the future's value. The function returns a future which is
flattened<R> Future<R> handleAsync(BiFunction<? super T,Throwable,? extends R> biFunction, Executor executor)
The handle function is executed asynchronously by the given executor.
R
- type of the handle function's return valuebiFunction
- applied to the result (normal and exceptional) of the futureexecutor
- used to execute the handle function asynchronously<R> Future<R> handle(BiFunction<? super T,Throwable,? extends R> biFunction)
R
- type of the handle function's return valuebiFunction
- applied to the result (normal and exceptional) of the future<U,R> Future<R> thenCombineAsync(Future<U> other, BiFunction<? super T,? super U,? extends R> biFunction, Executor executor)
The bi-function is executed asynchronously by the given executor.
U
- type of that future's return valueR
- type of the bi-function's return valueother
- future whose result is the right input to the bi-functionbiFunction
- applied to the result of this and that futureexecutor
- used to execute the bi-function asynchronously<U,R> Future<R> thenCombine(Future<U> other, BiFunction<? super T,? super U,? extends R> biFunction)
U
- type of that future's return valueR
- type of the bi-function's return valueother
- future whose result is the right input to the bi-functionbiFunction
- applied to the result of this and that futureCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.