It is an implementation of Promise, which exposes an additional {@link #set(Object)} and {@link #chain(Promise)} methods. Calling{@link #set(Object)} puts it in ready state, with value retrievable through{@link #get()} method. {@link #chain(Promise)} links state of this Settableto 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; }
@param < V> The type of value accepted and returned by this Settable.Use {@link Void} to represent Promise that indicates completion ofoperation that doesn't return a value.