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;
}
Modifier and Type | Method and Description |
---|---|
void |
chain(Promise<V> chainTo)
Used to chain this Settable with the passed in Promise.
|
V |
get() |
String |
getDescription() |
boolean |
isReady() |
void |
set(V value) |
void |
setDescription(String description) |
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()
get
in class Promise<V>
IllegalStateException
- If set() is never called for this instance of Settablepublic 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.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.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.IllegalStateException
- If the Promise it is chained to is already in the ready statepublic String getDescription()
getDescription
in class Promise<V>
AsyncScope.getAsynchronousThreadDumpAsString()
public void setDescription(String description)
description
- human readable description of what this Promise represents.Promise.getDescription()
Copyright © 2013 Amazon Web Services, Inc. All Rights Reserved.