|
||||||||||
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(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<? super A> success,
Effect<Throwable> failure)
Create a FutureCallback by composing two Effects. |
|
static
|
onFailureDo(Effect<Throwable> effect)
Create a FutureCallback from an Effect to be run if there is a
failure. |
|
static
|
onSuccessDo(Effect<? super 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<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(Throwable throwable)
Creates a new, rejected promise from the given Throwable and result
type. |
|
static
|
rejected(Throwable throwable,
Class<A> resultType)
Deprecated. Use rejected(Throwable) |
|
static
|
toPromise()
Creates a new, resolved promise for the specified concrete value. |
|
static
|
toRejectedPromise(Throwable t)
Creates a new, rejected promise from the given Throwable and result type. |
|
static
|
toRejectedPromise(Throwable t,
Class<A> resultType)
Deprecated. Use toRejectedPromise(Throwable) |
|
static
|
toResolvedPromise(A value)
Creates a new, resolved promise for the specified concrete value. |
|
static
|
when(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<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<List<A>> when(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> com.google.common.base.Function<A,Promise<A>> toPromise()
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(Throwable throwable, Class<A> resultType)
rejected(Throwable)
Throwable
and result
type.
throwable
- The throwableresultType
- The result type
public static <A> Promise<A> rejected(Throwable throwable)
Throwable
and result
type.
throwable
- The throwable
public static <A> Promise<A> toRejectedPromise(Throwable t, Class<A> resultType)
toRejectedPromise(Throwable)
Synonym for rejected(Throwable, Class)
t
- The throwableresultType
- The result type
public static <A> Promise<A> toRejectedPromise(Throwable t)
Synonym for rejected(Throwable, Class)
t
- The throwable
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(Future<A> future)
future
- The future delegate for the new promise
public static Effect<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<? super A> success, Effect<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<? super 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<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 |