T
- The type this Future will hold as resultpublic interface Future<T>
Modifier and Type | Method and Description |
---|---|
Future<T> |
filter(java.util.function.Predicate<T> predicate)
Creates a new
Future that will filter the successful value of this instance once it is completed. |
<R> Future<R> |
flatMap(java.util.function.Function<T,Future<R>> function)
Creates a new
Future that will hold the mapped successful value of this instance once it is completed. |
void |
forEach(java.util.function.Consumer<T> consumer)
Asynchronously processes the value in the Future once it is available.
|
boolean |
isCompleted()
Check if this Future is completed, with a value or an exception.
|
<R> Future<R> |
map(java.util.function.Function<T,R> function)
Creates a new
Future that will hold the mapped successful value of this instance once it is completed. |
void |
onComplete(java.util.function.Consumer<Try<T>> completeHandler)
Register a handler to be invoked if the Future gets completed with a value or a failure.
|
void |
onFailure(java.util.function.Consumer<Throwable> failureHandler)
Register a handler to be invoked if the Future gets completed with an exception.
|
void |
onSuccess(java.util.function.Consumer<T> successHandler)
Register a handler to be invoked if the Future gets completed with a value.
|
T |
result(long duration,
TimeUnit timeUnit)
Blocks and waits for this Future to complete.
|
Option<Try<T>> |
value()
The value of the future.
|
boolean isCompleted()
true
if completed, false
otherwise.Option<Try<T>> value()
Option
with the result.void onFailure(java.util.function.Consumer<Throwable> failureHandler)
failureHandler
- Consumer to invoke.void onSuccess(java.util.function.Consumer<T> successHandler)
successHandler
- Consumer to invoke.void onComplete(java.util.function.Consumer<Try<T>> completeHandler)
completeHandler
- Consumer to invoke.void forEach(java.util.function.Consumer<T> consumer)
onSuccess(Consumer)
but is here for completion keeping a consistent look and feel.consumer
- The consumer to digest the result<R> Future<R> map(java.util.function.Function<T,R> function)
Future
that will hold the mapped successful value of this instance once it is completed. R
- The type for the value held by the mapped futurefunction
- The function to apply<R> Future<R> flatMap(java.util.function.Function<T,Future<R>> function)
Future
that will hold the mapped successful value of this instance once it is completed. R
- The type for the value held by the mapped futurefunction
- The function to applyFuture<T> filter(java.util.function.Predicate<T> predicate)
Future
that will filter the successful value of this instance once it is completed. predicate
- The predicate to applyT result(long duration, TimeUnit timeUnit) throws Throwable, TimeoutException
duration
- The duration to blocktimeUnit
- The unit for the durationThrowable
- The error reported in case of a failureTimeoutException
- In case the waiting time is passedCopyright © 2015. All rights reserved.