Class CompleteExceptionallyPromise<T>
- All Implemented Interfaces:
AsyncComputation<T>,Promise<T>
Promise which is completed with an exception.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasync()Ensures thatPromisecompletes asynchronously: if thisPromiseis already completed, its completion will be posted to the next reactor tick.Returns a newPromisewhen both this and providedotherPromisescomplete.<U,V> Promise<V> combine(Promise<? extends U> other, io.activej.common.function.BiFunctionEx<? super T, ? super U, ? extends V> fn) Returns a newPromisethat, when this and the other givenPromiseboth complete, is executed with the two results as arguments to the supplied function.Returns thePromisewhich was completed first.io.activej.common.collection.Try<T>getTry()booleanbooleanbooleanisResult()<U> Promise<U>Returns a newPromisewhich is obtained by mapping a result and an exception ofthispromise to some other value.<U> Promise<U>Returns a newPromisewhich is obtained by mapping a result ofthispromise to some other value.<U> Promise<U>map(io.activej.common.function.FunctionEx<? super T, ? extends U> fn, io.activej.common.function.FunctionEx<Exception, ? extends U> exceptionFn) Returns a newPromisewhich is obtained by mapping either a result or an exception ofthispromise to some other values.mapException(io.activej.common.function.FunctionEx<Exception, Exception> exceptionFn) Returns a newPromisewhich is obtained by mapping an exception ofthispromise to some other exception.mapException(Class<E> clazz, io.activej.common.function.FunctionEx<? super E, ? extends Exception> exceptionFn) Returns a newPromisewhich is obtained by mapping an exception ofthispromise to some other exception.voidnext(NextPromise<? super T, ?> cb) Calls acallbackafterthispromise is completed, passing both a result and an exception of a promise to the callback.<U> Promise<U>then(AsyncBiFunctionEx<? super T, Exception, U> fn) Returns a newPromisewhich is obtained by mapping a result and an exception ofthispromise to some other promise.<U> Promise<U>then(AsyncFunctionEx<? super T, U> fn) Returns a newPromisewhich is obtained by mapping a result ofthispromise to some other promise.<U> Promise<U>then(AsyncFunctionEx<? super T, U> fn, AsyncFunctionEx<Exception, U> exceptionFn) Returns a newPromisewhich is obtained by mapping either a result or an exception ofthispromise to some other promises.<U> Promise<U>then(AsyncSupplierEx<U> fn) Returns a newPromisewhich is obtained by calling a provided supplier of a new promise.<U> Promise<U>thenCallback(CallbackBiFunctionEx<? super T, @Nullable Exception, U> fn) <U> Promise<U>thenCallback(CallbackFunctionEx<? super T, U> fn) <U> Promise<U>thenCallback(CallbackFunctionEx<? super T, U> fn, CallbackFunctionEx<Exception, U> exceptionFn) <U> Promise<U>thenCallback(CallbackSupplierEx<U> fn) WrapsPromiseintoCompletableFuture.toTry()ReturnsPromisethat always completes successfully with result or exception wrapped inTry.toVoid()Waits for result and discards it.whenComplete(io.activej.common.function.BiConsumerEx<? super T, Exception> fn) Subscribes given consumer to be executed after thisPromisecompletes (either successfully or exceptionally).whenComplete(io.activej.common.function.ConsumerEx<? super T> fn, io.activej.common.function.ConsumerEx<Exception> exceptionFn) Subscribes given consumers to be executed afterthisPromise completes (either successfully or exceptionally).whenComplete(io.activej.common.function.RunnableEx action) Subscribes given runnable to be executed after thisPromisecompletes (either successfully or exceptionally).whenException(io.activej.common.function.ConsumerEx<Exception> fn) Subscribes given consumer to be executed after thisPromisecompletes exceptionally.whenException(io.activej.common.function.RunnableEx action) Subscribes given runnable to be executed after thisPromisecompletes exceptionally.whenException(Class<? extends Exception> clazz, io.activej.common.function.RunnableEx action) Subscribes given runnable to be executed after thisPromisecompletes exceptionally and an exception of thisPromiseis an instance of a given exceptionClass.whenException(Class<E> clazz, io.activej.common.function.ConsumerEx<? super E> fn) Subscribes given consumer to be executed after thisPromisecompletes exceptionally and an exception of thisPromiseis an instance of a given exceptionClass.whenResult(io.activej.common.function.ConsumerEx<? super T> fn) Subscribes given consumer to be executed after thisPromisecompletes successfully.whenResult(io.activej.common.function.RunnableEx action) Subscribes given runnable to be executed after thisPromisecompletes successfully and a result of thisPromisesatisfy a givenPredicate.
-
Constructor Details
-
CompleteExceptionallyPromise
-
-
Method Details
-
isComplete
public boolean isComplete()- Specified by:
isCompletein interfacePromise<T>
-
isResult
public boolean isResult() -
isException
public boolean isException()- Specified by:
isExceptionin interfacePromise<T>
-
getResult
-
getException
- Specified by:
getExceptionin interfacePromise<T>
-
getTry
-
map
Description copied from interface:PromiseReturns a newPromisewhich is obtained by mapping a result ofthispromise to some other value. Ifthispromise is completed exceptionally, a mapping function will not be applied.A mapping function may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
-
map
public <U> Promise<U> map(io.activej.common.function.BiFunctionEx<? super T, Exception, ? extends U> fn) Description copied from interface:PromiseReturns a newPromisewhich is obtained by mapping a result and an exception ofthispromise to some other value. Ifthispromise is completed exceptionally, an exception passed to a mapping function is guaranteed to be not null.A {bi function} may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
-
map
public <U> Promise<U> map(io.activej.common.function.FunctionEx<? super T, ? extends U> fn, io.activej.common.function.FunctionEx<Exception, ? extends U> exceptionFn) Description copied from interface:PromiseReturns a newPromisewhich is obtained by mapping either a result or an exception ofthispromise to some other values. Ifthispromise is completed successfully, the first function will be called mapping the result to some other value. Otherwise, second function will be called mapping the exception to some other value.Each function may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
mapin interfacePromise<T>- Parameters:
fn- a function to map a result ofthispromise to some other valueexceptionFn- a function to map an exception ofthispromise to some other value- Returns:
- new
Promisewhose result is the result of either first or second function applied either to a result or an exception ofthispromise.
-
mapException
public Promise<T> mapException(io.activej.common.function.FunctionEx<Exception, Exception> exceptionFn) Description copied from interface:PromiseReturns a newPromisewhich is obtained by mapping an exception ofthispromise to some other exception. The mapping function will be called only ifthispromise completes exceptionallyA mapping function may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
mapExceptionin interfacePromise<T>- Parameters:
exceptionFn- a function to map an exception ofthispromise to some other value- Returns:
- new
Promisewhose result is the result of a mapping function applied either to an exception ofthispromise.
-
mapException
public <E extends Exception> Promise<T> mapException(Class<E> clazz, io.activej.common.function.FunctionEx<? super E, ? extends Exception> exceptionFn) Description copied from interface:PromiseReturns a newPromisewhich is obtained by mapping an exception ofthispromise to some other exception. The mapping function will be called only ifthispromise completes with an exception that is an instance of a givenClassA mapping function may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
mapExceptionin interfacePromise<T>- Parameters:
clazz- an exception class that exception is tested against. A mapping function is applied only if an exception ofthispromise is an instance of the specified classexceptionFn- a function to map an exception ofthispromise to some other value- Returns:
- new
Promisewhose result is the result of a mapping function applied either to an exception ofthispromise.
-
then
Description copied from interface:PromiseReturns a newPromisewhich is obtained by mapping a result ofthispromise to some other promise. Ifthispromise is completed exceptionally, a mapping function will not be applied.A mapping function may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
-
thenCallback
- Specified by:
thenCallbackin interfacePromise<T>
-
then
Description copied from interface:PromiseReturns a newPromisewhich is obtained by calling a provided supplier of a new promise. Ifthispromise is completed exceptionally, a supplier will not be called.A supplier may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
-
thenCallback
- Specified by:
thenCallbackin interfacePromise<T>
-
then
Description copied from interface:PromiseReturns a newPromisewhich is obtained by mapping a result and an exception ofthispromise to some other promise. Ifthispromise is completed exceptionally, an exception passed to a mapping function is guaranteed to be not null.A function may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
-
thenCallback
- Specified by:
thenCallbackin interfacePromise<T>
-
then
public <U> Promise<U> then(AsyncFunctionEx<? super T, U> fn, AsyncFunctionEx<Exception, U> exceptionFn) Description copied from interface:PromiseReturns a newPromisewhich is obtained by mapping either a result or an exception ofthispromise to some other promises. Ifthispromise is completed successfully, the first function will be called mapping the result to a promise of some other value. Otherwise, second function will be called mapping the exception to a promise of some other value.Each function may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
thenin interfacePromise<T>- Parameters:
fn- a function to map a result ofthispromise to a dofferent promiseexceptionFn- a function to map an exception ofthispromise a different promise- Returns:
- new
Promisewhich is a result of either first or second function applied either to a result or an exception ofthispromise.
-
thenCallback
public <U> Promise<U> thenCallback(CallbackFunctionEx<? super T, U> fn, CallbackFunctionEx<Exception, U> exceptionFn) - Specified by:
thenCallbackin interfacePromise<T>
-
whenComplete
Description copied from interface:PromiseSubscribes given consumer to be executed after thisPromisecompletes (either successfully or exceptionally). Returns a newPromise.A consumer may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenCompletein interfacePromise<T>- Parameters:
fn- a consumer that consumes a result and an exception ofthispromise
-
whenComplete
public Promise<T> whenComplete(io.activej.common.function.ConsumerEx<? super T> fn, io.activej.common.function.ConsumerEx<Exception> exceptionFn) Description copied from interface:PromiseSubscribes given consumers to be executed afterthisPromise completes (either successfully or exceptionally). The first consumer will be executed ifthisPromise completes successfully, otherwise the second promise will be executed. Returns a newPromise.Each consumer may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenCompletein interfacePromise<T>- Parameters:
fn- consumer that consumes a result ofthispromiseexceptionFn- consumer that consumes an exception ofthispromise
-
whenComplete
Description copied from interface:PromiseSubscribes given runnable to be executed after thisPromisecompletes (either successfully or exceptionally). Returns a newPromise.A runnable may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenCompletein interfacePromise<T>- Parameters:
action- runnable to be executed afterthispromise completes
-
whenResult
Description copied from interface:PromiseSubscribes given consumer to be executed after thisPromisecompletes successfully. Returns a newPromise.A consumer may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenResultin interfacePromise<T>- Parameters:
fn- consumer that consumes a result ofthispromise
-
whenResult
Description copied from interface:PromiseSubscribes given runnable to be executed after thisPromisecompletes successfully and a result of thisPromisesatisfy a givenPredicate. Returns a newPromise.A runnable may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenResultin interfacePromise<T>- Parameters:
action- runnable to be executed afterthispromise completes successfully
-
whenException
Description copied from interface:PromiseSubscribes given consumer to be executed after thisPromisecompletes exceptionally. Returns a newPromise.A consumer may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenExceptionin interfacePromise<T>- Parameters:
fn- consumer that consumes an exception ofthispromise
-
whenException
public <E extends Exception> Promise<T> whenException(Class<E> clazz, io.activej.common.function.ConsumerEx<? super E> fn) Description copied from interface:PromiseSubscribes given consumer to be executed after thisPromisecompletes exceptionally and an exception of thisPromiseis an instance of a given exceptionClass. Returns a newPromise.A consumer may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenExceptionin interfacePromise<T>- Parameters:
clazz- an exception class that exception is tested against. A consumer is called only if an exception ofthispromise is an instance of the specified classfn- consumer that consumes an exception ofthispromise
-
whenException
Description copied from interface:PromiseSubscribes given runnable to be executed after thisPromisecompletes exceptionally. Returns a newPromise.A runnable may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenExceptionin interfacePromise<T>- Parameters:
action- runnable to be executed afterthispromise completes exceptionally
-
whenException
public Promise<T> whenException(Class<? extends Exception> clazz, io.activej.common.function.RunnableEx action) Description copied from interface:PromiseSubscribes given runnable to be executed after thisPromisecompletes exceptionally and an exception of thisPromiseis an instance of a given exceptionClass. Returns a newPromise.A runnable may throw a checked exception. In this case the resulting promise is completed exceptionally with a thrown exception.
- Specified by:
whenExceptionin interfacePromise<T>- Parameters:
clazz- an exception class that exception is tested against. A consumer is called only if an exception ofthispromise is an instance of the specified classaction- runnable to be executed afterthispromise completes exceptionally and an exception of thisPromiseis an instance of a given exceptionClass.
-
combine
public <U,V> Promise<V> combine(Promise<? extends U> other, io.activej.common.function.BiFunctionEx<? super T, ? super U, ? extends V> fn) Description copied from interface:PromiseReturns a newPromisethat, when this and the other givenPromiseboth complete, is executed with the two results as arguments to the supplied function. -
both
Description copied from interface:PromiseReturns a newPromisewhen both this and providedotherPromisescomplete. -
either
Description copied from interface:PromiseReturns thePromisewhich was completed first. -
async
Description copied from interface:PromiseEnsures thatPromisecompletes asynchronously: if thisPromiseis already completed, its completion will be posted to the next reactor tick. Otherwise, does nothing. -
toTry
Description copied from interface:PromiseReturnsPromisethat always completes successfully with result or exception wrapped inTry. -
toVoid
Description copied from interface:PromiseWaits for result and discards it. -
next
Description copied from interface:PromiseCalls acallbackafterthispromise is completed, passing both a result and an exception of a promise to the callback. This method is similar toPromise.whenComplete(BiConsumerEx)but does not create or return a new promise. ACallbackinterface also prohibits throwing checked exceptions.In most cases
Promise.whenComplete(BiConsumerEx)is preferred. Fall back to using this method only if you expect a performance hit from constantly callingPromise.whenComplete(BiConsumerEx)and creating new promises as a result. -
subscribe
-
toCompletableFuture
Description copied from interface:PromiseWrapsPromiseintoCompletableFuture.- Specified by:
toCompletableFuturein interfacePromise<T>
-