Package io.activej.promise
Class SettablePromise<T>
java.lang.Object
io.activej.promise.AbstractPromise<T>
io.activej.promise.SettablePromise<T>
- Type Parameters:
T- result type
- All Implemented Interfaces:
AsyncComputation<T>,Callback<T>,Promise<T>,SettableCallback<T>
Represents a
Promise which can be completed or completedExceptionally
manually at once or later in the future.
Can be used as root Promise to start execution of chain of
Promises or when you want wrap your actions in Promise.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.activej.promise.AbstractPromise
AbstractPromise.EitherPromise<T>, AbstractPromise.PromiseBoth<T>, AbstractPromise.PromiseCombine<T,V, U> -
Field Summary
Fields inherited from class io.activej.promise.AbstractPromise
exception, next, result -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondescribe()voidSets the result of thisSettablePromiseand completes it.voidAccepts the provided values and performs this operation on them.voidSets exception and completes thisSettablePromiseexceptionally.booleanTries to set providedresultfor thisSettablePromiseif it is not completed yet.booleanTries to set result or exception for thisSettablePromiseif it is not completed yet.booleanTries to set providedeexception for thisSettablePromiseif it is not completed yet.Methods inherited from class io.activej.promise.AbstractPromise
async, both, combine, complete, complete, completeExceptionally, either, getException, getResult, getTry, isComplete, isException, isResult, map, map, map, mapException, mapException, next, recycleToVoid, reset, resetCallbacks, subscribe, then, then, then, then, thenCallback, thenCallback, thenCallback, thenCallback, toCompletableFuture, toString, toTry, toVoid, tryComplete, tryComplete, tryCompleteExceptionally, whenComplete, whenComplete, whenComplete, whenException, whenException, whenException, whenException, whenResult, whenResultMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.activej.promise.SettableCallback
accept, isComplete
-
Constructor Details
-
SettablePromise
public SettablePromise()
-
-
Method Details
-
set
Accepts the provided values and performs this operation on them. If theException eisnull, providedresultwill be set to thisSettablePromise.Otherwise,
Exception ewill be set.- Specified by:
setin interfaceSettableCallback<T>- Parameters:
result- a value to be set to thisSettablePromiseifeisnulle- aException, which will be set to thisSettablePromiseif notnull
-
set
Sets the result of thisSettablePromiseand completes it.AssertionErroris thrown when you try to set result for an already completedPromise.- Specified by:
setin interfaceSettableCallback<T>
-
setException
Sets exception and completes thisSettablePromiseexceptionally.AssertionErroris thrown when you try to set exception for an already completedPromise.- Specified by:
setExceptionin interfaceSettableCallback<T>- Parameters:
e- exception
-
trySet
Tries to set result or exception for thisSettablePromiseif it is not completed yet. Otherwise, does nothing.- Specified by:
trySetin interfaceSettableCallback<T>
-
trySet
Tries to set providedresultfor thisSettablePromiseif it is not completed yet. Otherwise, does nothing.- Specified by:
trySetin interfaceSettableCallback<T>
-
trySetException
Tries to set providedeexception for thisSettablePromiseif it is not completed yet. Otherwise, does nothing.- Specified by:
trySetExceptionin interfaceSettableCallback<T>
-
describe
- Overrides:
describein classAbstractPromise<T>
-