Package ratpack.exec
Interface Downstream<T>
-
- Type Parameters:
T- the type of value emitted downstream
- All Known Implementing Classes:
Promised
public interface Downstream<T>A consumer of a single asynchronous value.Downstreams
connecttoupstreams. Once connected, an upstream will invoke only one of either thesuccess(T),error(java.lang.Throwable)orcomplete()methods exactly once.- See Also:
Promise.transform(Function)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidaccept(com.google.common.util.concurrent.ListenableFuture<? extends T> future)Sends the result of the future downstream.default voidaccept(CompletionStage<? extends T> completionStage)Sends the result of a CompletionStage downstream.default voidaccept(ExecResult<? extends T> result)Signals this downstream, based on the given result.default voidaccept(Result<? extends T> result)Signals this downstream, based on the given result.voidcomplete()Signals that the upstream will not be providing a value, as it has terminated.default <I extends T,A>
CompletionHandler<I,A>completionHandler()Creates a JDKCompletionHandlerthat connects to this downstream.voiderror(Throwable throwable)Signals the unsuccessful production of the upstream value.default Downstream<T>onComplete(Block block)Wrap this downstream, using the given action as the implementation of thecomplete()method.default Downstream<T>onError(Action<? super Throwable> action)Wrap this downstream, using the given action as the implementation of theerror(Throwable)method.default <O> Downstream<O>onSuccess(Action<? super O> action)Wrap this downstream, using the given action as the implementation of thesuccess(T)method.voidsuccess(T value)Signals the successful production of the upstream value.
-
-
-
Method Detail
-
success
void success(T value)
Signals the successful production of the upstream value.- Parameters:
value- the upstream value
-
error
void error(Throwable throwable)
Signals the unsuccessful production of the upstream value.- Parameters:
throwable- what went wrong
-
complete
void complete()
Signals that the upstream will not be providing a value, as it has terminated.
-
onSuccess
default <O> Downstream<O> onSuccess(Action<? super O> action)
Wrap this downstream, using the given action as the implementation of thesuccess(T)method.All
error(java.lang.Throwable)andcomplete()signals will be forwarded tothisdownstream, and the given action called with the value ifsuccess(T)is signalled.- Type Parameters:
O- the type of item accepted- Parameters:
action- the implementation of the success signal receiver for the returned downstream- Returns:
- a downstream
-
onError
default Downstream<T> onError(Action<? super Throwable> action)
Wrap this downstream, using the given action as the implementation of theerror(Throwable)method.All
success(T)andcomplete()signals will be forwarded tothisdownstream, and the given action called with the value ifsuccess(T)is signalled.- Parameters:
action- the implementation of the error signal receiver for the returned downstream- Returns:
- a downstream
-
onComplete
default Downstream<T> onComplete(Block block)
Wrap this downstream, using the given action as the implementation of thecomplete()method.All
success(T)anderror(java.lang.Throwable)signals will be forwarded tothisdownstream, and the given action called with the value ifcomplete()is signalled.- Parameters:
block- the implementation of the complete signal receiver for the returned downstream- Returns:
- a downstream
-
accept
default void accept(ExecResult<? extends T> result)
Signals this downstream, based on the given result.- Parameters:
result- the result to signal
-
accept
default void accept(Result<? extends T> result)
Signals this downstream, based on the given result.- Parameters:
result- the result to signal
-
accept
default void accept(CompletionStage<? extends T> completionStage)
Sends the result of a CompletionStage downstream.- Parameters:
completionStage- the CompletionStage to consume the value of
-
accept
default void accept(com.google.common.util.concurrent.ListenableFuture<? extends T> future)
Sends the result of the future downstream.- Parameters:
future- the future to consume the value of
-
completionHandler
default <I extends T,A> CompletionHandler<I,A> completionHandler()
Creates a JDKCompletionHandlerthat connects to this downstream.- Returns:
- a completion handler
- Since:
- 1.2
-
-