V - The type of value accepted and returned by this Settable.Use
Void to represent Promise that indicates completion of
operation that doesn't return a value.public class Settable<V> extends Promise<V>
set(Object) and chain(Promise) methods. Calling
set(Object) puts it in ready state, with value retrievable through
get() method. chain(Promise) links state of this Settable
to another Promise. When another promise changes its state to ready the
chained one is also becomes ready.
Use settable.set(null) to set Settable<Void>
to the ready state.
Settable is frequently used to return data from code contained in anonymous classes. For example:
Promise<Integer> foo() {
final Settable<Integer> result = new Settable<Integer>();
new TryCatch() {
protected void doTry() throws Throwable {
Promise<Integer> activity1Result = activities.callActivity1();
result.chain(activity1Result);
}
protected void doCatch(Throwable e) throws Throwable {
Promise<Void> handled = handleFailure(e);
rethrow(e, handled);
}
};
return result;
}
| 修飾子とタイプ | メソッドと説明 |
|---|---|
protected void |
addCallback(java.lang.Runnable callback)
Compliant implementation should notify callbacks after promise is set to
ready state.
|
void |
chain(Promise<V> chainTo)
Used to chain this Settable with the passed in Promise.
|
V |
get() |
java.lang.String |
getDescription() |
boolean |
isReady() |
protected void |
removeCallback(java.lang.Runnable callback) |
void |
set(V value) |
void |
setDescription(java.lang.String description) |
java.lang.String |
toString() |
void |
unchain()
Used to unchain this Settable from the Promise object passed in last
invocation of chain.
|
public Settable(V value)
public Settable()
public V get()
public boolean isReady()
public void set(V value)
value - Object to return when get() is called for this Settable. Use
null to set Settable<Void> to
the ready state.java.lang.IllegalStateException - if the Promise is already in ready statepublic void chain(Promise<V> chainTo)
chainTo - Promise object to chain this Settable to. Chaining to
null equates calling set(Object) with
null argument.java.lang.IllegalStateException - if Settable is already in ready state or it is already
chained to some other Promiseunchain()public void unchain()
TryCatchFinally.doCatch(Throwable) blocks. It is safe to call
unchain if chain is never called for this Settable.java.lang.IllegalStateException - If the Promise it is chained to is already in the ready stateprotected void addCallback(java.lang.Runnable callback)
PromiseaddCallback クラス内 Promise<V>callback - callback to notifyprotected void removeCallback(java.lang.Runnable callback)
removeCallback クラス内 Promise<V>public java.lang.String getDescription()
getDescription クラス内 Promise<V>AsyncScope.getAsynchronousThreadDumpAsString()public void setDescription(java.lang.String description)
description - human readable description of what this Promise represents.Promise.getDescription()public java.lang.String toString()
toString クラス内 java.lang.Object