|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.common.collect.ForwardingObject
com.google.common.util.concurrent.ForwardingFuture<V>
com.google.common.util.concurrent.ForwardingListenableFuture<A>
com.atlassian.util.concurrent.ForwardingPromise<A>
@Beta public abstract class ForwardingPromise<A>
A promise which forwards all its method calls to another promise. Subclasses should override one or more methods to modify the behavior of the backing Promise as desired per the decorator pattern.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.google.common.util.concurrent.ForwardingListenableFuture |
---|
com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture<V> |
Nested classes/interfaces inherited from class com.google.common.util.concurrent.ForwardingFuture |
---|
com.google.common.util.concurrent.ForwardingFuture.SimpleForwardingFuture<V> |
Constructor Summary | |
---|---|
protected |
ForwardingPromise()
Constructor for use by subclasses. |
Method Summary | ||
---|---|---|
A |
claim()
Blocks the thread waiting for a result. |
|
protected abstract Promise<A> |
delegate()
|
|
Promise<A> |
done(Effect<? super A> e)
Registers a callback to be called when the promised object is available. |
|
Promise<A> |
fail(Effect<Throwable> e)
Registers a callback to be called when an exception is thrown. |
|
|
flatMap(com.google.common.base.Function<? super A,? extends Promise<? extends B>> function)
Transforms this promise from one type to another by way of a transformation function that returns a new Promise, leaving the strategy for that promise production up to the function. |
|
|
fold(com.google.common.base.Function<Throwable,? extends B> handleThrowable,
com.google.common.base.Function<? super A,? extends B> function)
Transform this promise from one type to another, also providing a strategy for dealing with any exceptions encountered. |
|
|
map(com.google.common.base.Function<? super A,? extends B> function)
Transforms this Promise from one type to another by way of a
transformation function. |
|
Promise<A> |
recover(com.google.common.base.Function<Throwable,? extends A> handleThrowable)
Recover from an exception using the supplied exception strategy |
|
Promise<A> |
then(com.google.common.util.concurrent.FutureCallback<? super A> callback)
Registers a FutureCallback to handle both success and failure (exception) cases. |
Methods inherited from class com.google.common.util.concurrent.ForwardingListenableFuture |
---|
addListener |
Methods inherited from class com.google.common.util.concurrent.ForwardingFuture |
---|
cancel, get, get, isCancelled, isDone |
Methods inherited from class com.google.common.collect.ForwardingObject |
---|
toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.google.common.util.concurrent.ListenableFuture |
---|
addListener |
Methods inherited from interface java.util.concurrent.Future |
---|
cancel, get, get, isCancelled, isDone |
Constructor Detail |
---|
protected ForwardingPromise()
Method Detail |
---|
protected abstract Promise<A> delegate()
delegate
in class com.google.common.util.concurrent.ForwardingListenableFuture<A>
public A claim()
Promise
claim
in interface Promise<A>
public Promise<A> done(Effect<? super A> e)
Promise
done
in interface Promise<A>
e
- The effect to perform with the result
public Promise<A> fail(Effect<Throwable> e)
Promise
fail
in interface Promise<A>
e
- The effect to perform with the throwable
public Promise<A> then(com.google.common.util.concurrent.FutureCallback<? super A> callback)
Promise
See Promises.futureCallback(Effect, Effect)
Promises.onSuccessDo(Effect)
and
Promises.onFailureDo(Effect)
for easy ways of turning an
Effect
into a FutureCallback
then
in interface Promise<A>
callback
- The future callback
public <B> Promise<B> map(com.google.common.base.Function<? super A,? extends B> function)
Promise
Promise
from one type to another by way of a
transformation function.
Note: This is designed for cases in which the transformation is fast and
lightweight, as the method is performed on the same thread as the thing
producing this promise. For more details see the note on
Futures.transform(Future, Function)
.
map
in interface Promise<A>
function
- The transformation function
public <B> Promise<B> flatMap(com.google.common.base.Function<? super A,? extends Promise<? extends B>> function)
Promise
Note this is known as flatMap as it first maps to a
Promise<Promise<A>>
and then flattens that out
into a single layer Promise.
flatMap
in interface Promise<A>
function
- The transformation function to a new Promise value
public Promise<A> recover(com.google.common.base.Function<Throwable,? extends A> handleThrowable)
Promise
recover
in interface Promise<A>
handleThrowable
- rehabilitate the exception with a value of type B
public <B> Promise<B> fold(com.google.common.base.Function<Throwable,? extends B> handleThrowable, com.google.common.base.Function<? super A,? extends B> function)
Promise
fold
in interface Promise<A>
handleThrowable
- rehabilitate the exception with a value of type Bfunction
- mapping function
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |