T - the generic type of the values that complete the callbackpublic interface CompletableCallback<T>
complete(Object) method is
invoked, or completed exceptionally when error(Throwable) is used instead. Per each instance, only one of those
methods should be called, and they should be called only once.
This interface also provides some utility methods for functional composition of several callbacks.
Support for void processes can be achieved using Void as the generic param <T> and using null when
invoking complete(Object)
| Modifier and Type | Method and Description |
|---|---|
static <T> CompletableCallback<T> |
always(Runnable runnable)
Returns a new callback which always executes the given
runnable upon completion, regardless of said completion being
normal or exceptional. |
default CompletableCallback<T> |
andThen(CompletableCallback<T> afterCallback)
Returns a new composed callback which propagates the completion signal to the given
afterCallback AFTER this
callback has finished executing its complete(Object) or error(Throwable) methods. |
default CompletableCallback<T> |
andThen(Consumer<T> consumer)
Returns a new composed callback which propagates the normal completion signal to the given
consumer AFTER
this callback has finished executing its complete(Object) method. |
default CompletableCallback<T> |
before(CompletableCallback<T> beforeCallback)
Returns a new composed callback which propagates the completion signal to the given
beforeCallback BEFORE the
complete(Object) or error(Throwable) methods are executed on this callback. |
default CompletableCallback<T> |
before(Consumer<T> consumer)
Returns a new composed callback which propagates the normal completion signal to the given
beforeCallback BEFORE the
complete(Object) method is executed on this callback. |
void |
complete(T value)
Invoked when processing completed successfully.
|
static <T> CompletableCallback<T> |
empty()
Returns an empty callback which does nothing
|
void |
error(Throwable e)
This method is invoked when the process fails to execute.
|
default CompletableCallback<T> |
finallyAfter(Runnable runnable)
Returns a new composed callback which always invokes the given
runnable AFTER this callback is completed
either normally or exceptionally. |
default CompletableCallback<T> |
finallyBefore(Runnable runnable)
Returns a new composed callback which always invokes the given
runnable BEFORE this callback is completed
either normally or exceptionally. |
static <T> CompletableCallback<T> empty()
T - the generic type of the callbackstatic <T> CompletableCallback<T> always(Runnable runnable)
runnable upon completion, regardless of said completion being
normal or exceptional.T - the callback's generic typerunnable - the task to runvoid complete(T value)
null is allowed.value - the processing resultvoid error(Throwable e)
e - the exception founddefault CompletableCallback<T> andThen(Consumer<T> consumer)
consumer AFTER
this callback has finished executing its complete(Object) method.
Notice that if this callback throws exceptions, then the consumer will never be invoked
consumer - the consumer to composedefault CompletableCallback<T> andThen(CompletableCallback<T> afterCallback)
afterCallback AFTER this
callback has finished executing its complete(Object) or error(Throwable) methods.
Notice that if this callback throws exceptions, then the completion signal will never reach the afterCallback
afterCallback - the callback to composedefault CompletableCallback<T> before(Consumer<T> consumer)
beforeCallback BEFORE the
complete(Object) method is executed on this callback.
Notice that if the consumer throws exception, the completion signal will never reach this callback.
consumer - the consumer to composedefault CompletableCallback<T> before(CompletableCallback<T> beforeCallback)
beforeCallback BEFORE the
complete(Object) or error(Throwable) methods are executed on this callback.
Notice that if the beforeCallback throws exception, the completion signal will never reach this callback.
beforeCallback - the callback to composedefault CompletableCallback<T> finallyBefore(Runnable runnable)
runnable BEFORE this callback is completed
either normally or exceptionally.
Notice that if the runnable throws exception, the completion signal will never reach this callback.
runnable - the task to execute upon completion.default CompletableCallback<T> finallyAfter(Runnable runnable)
runnable AFTER this callback is completed
either normally or exceptionally.
Notice that if this callback throws exception, the runnable will never be invoked.
runnable - the task to execute upon completion.Copyright © 2025 MuleSoft, Inc.. All rights reserved.