|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.util.concurrent.Promises
@Beta public final class Promises
Library of utility Promise functions
| Method Summary | ||
|---|---|---|
static
|
forFuture(java.util.concurrent.Future<A> future)
Creates a promise from the given future. |
|
static
|
forListenableFuture(com.google.common.util.concurrent.ListenableFuture<A> future)
Creates a promise from the given future. |
|
static
|
futureCallback(Effect<A> success,
Effect<java.lang.Throwable> failure)
Create a FutureCallback by composing two Effects. |
|
static
|
onFailureDo(Effect<java.lang.Throwable> effect)
Create a FutureCallback from an Effect to be run if there is a
failure. |
|
static
|
onSuccessDo(Effect<A> effect)
Create a FutureCallback from an Effect to be run if there is a
success. |
|
static
|
promise(A value)
Creates a new, resolved promise for the specified concrete value. |
|
static Effect<java.lang.Throwable> |
reject(com.google.common.util.concurrent.SettableFuture<?> delegate)
Creates a new Effect that forwards a promise's fail events to the
specified future delegate's SettableFuture.setException(Throwable)
method -- that is, the new callback rejects the delegate future if invoked. |
|
static
|
rejected(java.lang.Throwable throwable,
java.lang.Class<A> resultType)
Creates a new, rejected promise from the given Throwable and result
type. |
|
static
|
toRejectedPromise(java.lang.Throwable t,
java.lang.Class<A> resultType)
Creates a new, rejected promise from the given Throwable and result type. |
|
static
|
toResolvedPromise(A value)
Creates a new, resolved promise for the specified concrete value. |
|
static
|
when(java.lang.Iterable<? extends Promise<? extends A>> promises)
Returns a new Promise representing the status of a list of other
promises. |
|
static
|
when(Promise<? extends A>... promises)
Returns a new Promise representing the status of a list of other
promises. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <A> Promise<java.util.List<A>> when(Promise<? extends A>... promises)
Promise representing the status of a list of other
promises.
promises - The promises that the new promise should track
public static <A> Promise<java.util.List<A>> when(java.lang.Iterable<? extends Promise<? extends A>> promises)
Promise representing the status of a list of other
promises. More generally this is known as {code}sequence{code} as both List
and Promise are traversable monads.
promises - The promises that the new promise should track
public static <A> Promise<A> promise(A value)
value - The value for which a promise should be created
public static <A> Promise<A> toResolvedPromise(A value)
Synonym for promise(Object).
value - The value for which a promise should be created
public static <A> Promise<A> rejected(java.lang.Throwable throwable,
java.lang.Class<A> resultType)
Throwable and result
type.
throwable - The throwableresultType - The result type
public static <A> Promise<A> toRejectedPromise(java.lang.Throwable t,
java.lang.Class<A> resultType)
Synonym for rejected(Throwable, Class)
t - The throwableresultType - The result type
public static <A> Promise<A> forListenableFuture(com.google.common.util.concurrent.ListenableFuture<A> future)
future - The future delegate for the new promise
public static <A> Promise<A> forFuture(java.util.concurrent.Future<A> future)
future - The future delegate for the new promise
public static Effect<java.lang.Throwable> reject(com.google.common.util.concurrent.SettableFuture<?> delegate)
Effect that forwards a promise's fail events to the
specified future delegate's SettableFuture.setException(Throwable)
method -- that is, the new callback rejects the delegate future if invoked.
delegate - The future to be rejected on a fail event
public static <A> com.google.common.util.concurrent.FutureCallback<A> futureCallback(Effect<A> success,
Effect<java.lang.Throwable> failure)
FutureCallback by composing two Effects.
success - To run if the Future is successfulfailure - To run if the Future fails
public static <A> com.google.common.util.concurrent.FutureCallback<A> onSuccessDo(Effect<A> effect)
FutureCallback from an Effect to be run if there is a
success.
effect - To be passed the produced value if it happens
public static <A> com.google.common.util.concurrent.FutureCallback<A> onFailureDo(Effect<java.lang.Throwable> effect)
FutureCallback from an Effect to be run if there is a
failure.
effect - To be passed an exception if it happens
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||