T
- the type of future value that is visitedpublic static class SimpleFutureVisitor.Builder<T> extends Object
Consumer
s and Runnable
s.
If any action is not defined when building the visitor, the default implementation in
SimpleFutureVisitor
is used.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
FutureVisitor<T> |
build()
Builds a visitor using the action definitions specified.
|
SimpleFutureVisitor.Builder<T> |
defaultAction(Runnable defaultAction)
Defines the default action for a visitor.
|
SimpleFutureVisitor.Builder<T> |
onCancel(Runnable onCancel)
Defines the action for visiting cancelled futures.
|
SimpleFutureVisitor.Builder<T> |
onFailure(Consumer<? super Throwable> onFailure)
Defines the action for visiting failed futures.
|
SimpleFutureVisitor.Builder<T> |
onSuccess(Consumer<? super T> onSuccess)
Defines the action for visiting successful futures.
|
public SimpleFutureVisitor.Builder<T> defaultAction(Runnable defaultAction)
defaultAction
- a runnable that performs the default actionthis
, for method chainingpublic SimpleFutureVisitor.Builder<T> onSuccess(Consumer<? super T> onSuccess)
onSuccess
- a consumer that accepts the future result and performs the action for
successful futuresthis
, for method chainingpublic SimpleFutureVisitor.Builder<T> onFailure(Consumer<? super Throwable> onFailure)
onFailure
- a consumer that accepts the cause of failure and performs the action for
failed futuresthis
, for method chainingpublic SimpleFutureVisitor.Builder<T> onCancel(Runnable onCancel)
onCancel
- a runnable that performs the action for cancelled futuresthis
, for method chainingpublic FutureVisitor<T> build()
SimpleFutureVisitor
that overrides default behavior using actions
defined via this builder