类 AbstractPromise<D>
java.lang.Object
cn.dinodev.spring.commons.promise.AbstractPromise<D>
- 直接已知子类:
DeferredObject
- 作者:
- Cody Lu
-
嵌套类概要
嵌套类从接口继承的嵌套类/接口 cn.dinodev.spring.commons.promise.Promise
Promise.State -
字段概要
字段修饰符和类型字段说明protected final List<AlwaysCallback<? super D>>protected Throwableprotected Dprotected Promise.State -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明always(AlwaysCallback<? super D> callback) This method will registerAlwaysCallbackso that when a Deferred object is either resolved (Deferred.resolve(Object)) or rejected (Deferred#reject(Object)),AlwaysCallbackwill be triggered.This method will registerDoneCallbackso that when a Deferred object is resolved (Deferred.resolve(Object)),DoneCallbackwill be triggered.This method will registerFailCallbackso that when a Deferred object is rejected (Deferred#reject(Object)),FailCallbackwill be triggered.get()get the resolved value, return defaultValue for rejectedget the resolved value, return defaultSupplier‘s result for rejectedprotected voidhandleException(AbstractPromise.CallbackType callbackType, Exception e) booleanQueries the state of this promise, returningtrueiff it isState.PENDING.booleanQueries the state of this promise, returningtrueiff it isState.REJECTED.booleanQueries the state of this promise, returningtrueiff it isState.RESOLVED.state()状态Equivalent toPromise.done(DoneCallback)Equivalent toPromise.done(DoneCallback).Promise.fail(FailCallback)protected voidtriggerAlways(AlwaysCallback<? super D> callback, Promise.State state, D resolve, Throwable reject) protected voidtriggerAlways(Promise.State state, D resolve, Throwable reject) protected voidtriggerDone(D resolved) protected voidtriggerDone(Consumer<? super D> callback, D resolved) protected voidtriggerFail(Throwable rejected) protected voidtriggerFail(Consumer<Throwable> callback, Throwable rejected) voidThis method will wait as long as the State is Pending.voidwaitSafely(long timeout) This method will wait when the State is Pending, and return when timeout has reached.
-
字段详细资料
-
state
-
doneCallbacks
-
failCallbacks
-
alwaysCallbacks
-
resolveResult
-
rejectResult
-
-
构造器详细资料
-
AbstractPromise
public AbstractPromise()
-
-
方法详细资料
-
state
从接口复制的说明:Promise状态 -
done
从接口复制的说明:PromiseThis method will registerDoneCallbackso that when a Deferred object is resolved (Deferred.resolve(Object)),DoneCallbackwill be triggered. If the Deferred object is already resolved then theDoneCallbackis triggered immediately. You can register multipleDoneCallbackby calling the method multiple times. The order of callback trigger is based on the order they have been registered.promise.progress(new DoneCallback(){ public void onDone(Object done) { ... } }); -
fail
从接口复制的说明:PromiseThis method will registerFailCallbackso that when a Deferred object is rejected (Deferred#reject(Object)),FailCallbackwill be triggered. If the Deferred object is already rejected then theFailCallbackis triggered immediately. You can register multipleFailCallbackby calling the method multiple times. The order of callback trigger is based on the order they have been registered.promise.fail(new FailCallback(){ public void onFail(Object rejection) { ... } }); -
always
从接口复制的说明:PromiseThis method will registerAlwaysCallbackso that when a Deferred object is either resolved (Deferred.resolve(Object)) or rejected (Deferred#reject(Object)),AlwaysCallbackwill be triggered. If the Deferred object is already resolved or rejected then theAlwaysCallbackis triggered immediately. You can register multipleAlwaysCallbackby calling the method multiple times. The order of callback trigger is based on the order they have been registered.AlwaysCallbacks are triggered after anyDoneCallbackorFailCallbackrespectively.promise.always(new AlwaysCallback(){ public void onAlways(State state, Object result, Object rejection) { if (state == State.RESOLVED) { // do something with result } else { // do something with rejection } } });- 指定者:
always在接口中Promise<D>- 参数:
callback- the callback to be triggered- 返回:
thisfor chaining more calls- 另请参阅:
-
Deferred.resolve(Object)Deferred#reject(Object)
-
triggerDone
-
triggerDone
-
triggerFail
-
triggerFail
-
triggerAlways
-
triggerAlways
protected void triggerAlways(AlwaysCallback<? super D> callback, Promise.State state, D resolve, Throwable reject) -
then
从接口复制的说明:PromiseEquivalent toPromise.done(DoneCallback)- 指定者:
then在接口中Promise<D>- 参数:
callback- seePromise.done(DoneCallback)- 返回:
thisfor chaining more calls
-
then
从接口复制的说明:PromiseEquivalent toPromise.done(DoneCallback).Promise.fail(FailCallback)- 指定者:
then在接口中Promise<D>- 参数:
doneCallback- seePromise.done(DoneCallback)failCallback- seePromise.fail(FailCallback)- 返回:
thisfor chaining more calls
-
isPending
public boolean isPending()从接口复制的说明:PromiseQueries the state of this promise, returningtrueiff it isState.PENDING. -
isResolved
public boolean isResolved()从接口复制的说明:PromiseQueries the state of this promise, returningtrueiff it isState.RESOLVED.- 指定者:
isResolved在接口中Promise<D>- 返回:
trueif the current state of this promise isState.RESOLVED,falseotherwise.- 另请参阅:
-
isRejected
public boolean isRejected()从接口复制的说明:PromiseQueries the state of this promise, returningtrueiff it isState.REJECTED.- 指定者:
isRejected在接口中Promise<D>- 返回:
trueif the current state of this promise isState.REJECTED,falseotherwise.- 另请参阅:
-
waitSafely
从接口复制的说明:PromiseThis method will wait as long as the State is Pending. This method will return fast when State is not Pending.- 指定者:
waitSafely在接口中Promise<D>- 抛出:
InterruptedException- if thread is interrupted while waiting
-
waitSafely
从接口复制的说明:PromiseThis method will wait when the State is Pending, and return when timeout has reached. This method will return fast when State is not Pending.- 指定者:
waitSafely在接口中Promise<D>- 参数:
timeout- the maximum time to wait in milliseconds- 抛出:
InterruptedException- if thread is interrupted while waiting
-
get
-
getOrElse
从接口复制的说明:Promiseget the resolved value, return defaultValue for rejected -
getOrElse
从接口复制的说明:Promiseget the resolved value, return defaultSupplier‘s result for rejected -
handleException
-