Top Description Constructors Methods
org.osgi.util.promise

public Class Promises

extends Object
Class Inheritance
Static Imports
org.osgi.util.promise.PromiseFactory.defaultFactory

Static helper methods for Promises.

These methods return Promises which use the default callback executor and default scheduled executor. See PromiseFactory for similar methods which use executors other than the default executors.

Author
$Id: 17b3c90100cf434a29a7e793853f721c146a7466 $
See Also
PromiseFactory

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
The value type of the List value associated with the returned Promise.
T
,
A subtype of the value type of the List value associated with the returned Promise.
S extends T
>
Promise<List<T>>

Returns:

A Promise which uses the default callback executor and default scheduled executor that is resolved only when all the specified Promises are resolved. The returned Promise must be successfully resolved with a List of the values in the order of the specified Promises if all the specified Promises are successfully resolved. The List in the returned Promise is the property of the caller and is modifiable. The returned Promise must be resolved with a failure of FailedPromisesException if any of the specified Promises are resolved with a failure. The failure FailedPromisesException must contain all of the specified Promises which resolved with a failure.
all
(Collection<Promise<S>>
The Promises which must be resolved before the returned Promise must be resolved. Must not be null and all of the elements in the collection must not be null.
promises
)

Returns a new Promise that is a latch on the resolution of the specified Promises.

public static <
The value type associated with the specified Promises.
T
>
Promise<List<T>>

Returns:

A Promise which uses the default callback executor and scheduled executor that is resolved only when all the specified Promises are resolved. The returned Promise must be successfully resolved with a List of the values in the order of the specified Promises if all the specified Promises are successfully resolved. The List in the returned Promise is the property of the caller and is modifiable. The returned Promise must be resolved with a failure of FailedPromisesException if any of the specified Promises are resolved with a failure. The failure FailedPromisesException must contain all of the specified Promises which resolved with a failure.
all
(Promise<? extends T>...
The Promises which must be resolved before the returned Promise must be resolved. Must not be null and all of the arguments must not be null.
promises
)

Returns a new Promise that is a latch on the resolution of the specified Promises.

public static <
The value type associated with the returned Promise.
T
>
Promise<T>

Returns:

A new Promise which uses the default callback executor and default scheduled executor that has been resolved with the specified failure.
failed
(Throwable
The failure of the resolved Promise. Must not be null.
failure
)

Returns a new Promise that has been resolved with the specified failure.

public static <
The value type associated with the returned Promise.
T
>
Promise<T>

Returns:

A new Promise which uses the default callback executor and default scheduled executor that has been resolved with the specified value.
resolved
(T
The value of the resolved Promise.
value
)

Returns a new Promise that has been resolved with the specified value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Promisesback to summary
private Promises()

Method Detail

allback to summary
public static <T, S extends T> Promise<List<T>> all(Collection<Promise<S>> promises)

Returns a new Promise that is a latch on the resolution of the specified Promises.

The returned Promise acts as a gate and must be resolved after all of the specified Promises are resolved.

Parameters
<T>
The value type of the List value associated with the returned Promise.
<S>
A subtype of the value type of the List value associated with the returned Promise.
promises:Collection<Promise<S>>

The Promises which must be resolved before the returned Promise must be resolved. Must not be null and all of the elements in the collection must not be null.

Returns:Promise<List<T>>

A Promise which uses the default callback executor and default scheduled executor that is resolved only when all the specified Promises are resolved. The returned Promise must be successfully resolved with a List of the values in the order of the specified Promises if all the specified Promises are successfully resolved. The List in the returned Promise is the property of the caller and is modifiable. The returned Promise must be resolved with a failure of FailedPromisesException if any of the specified Promises are resolved with a failure. The failure FailedPromisesException must contain all of the specified Promises which resolved with a failure.

See Also
PromiseFactory#all(Collection)
allback to summary
public static <T> Promise<List<T>> all(Promise<? extends T>... promises)

Returns a new Promise that is a latch on the resolution of the specified Promises.

The new Promise acts as a gate and must be resolved after all of the specified Promises are resolved.

Parameters
<T>
The value type associated with the specified Promises.
promises:Promise<? extends T>[]

The Promises which must be resolved before the returned Promise must be resolved. Must not be null and all of the arguments must not be null.

Returns:Promise<List<T>>

A Promise which uses the default callback executor and scheduled executor that is resolved only when all the specified Promises are resolved. The returned Promise must be successfully resolved with a List of the values in the order of the specified Promises if all the specified Promises are successfully resolved. The List in the returned Promise is the property of the caller and is modifiable. The returned Promise must be resolved with a failure of FailedPromisesException if any of the specified Promises are resolved with a failure. The failure FailedPromisesException must contain all of the specified Promises which resolved with a failure.

Annotations
@SafeVarargs
See Also
PromiseFactory#all(Collection)
failedback to summary
public static <T> Promise<T> failed(Throwable failure)

Returns a new Promise that has been resolved with the specified failure.

Parameters
<T>
The value type associated with the returned Promise.
failure:Throwable

The failure of the resolved Promise. Must not be null.

Returns:Promise<T>

A new Promise which uses the default callback executor and default scheduled executor that has been resolved with the specified failure.

See Also
PromiseFactory#failed(Throwable)
resolvedback to summary
public static <T> Promise<T> resolved(T value)

Returns a new Promise that has been resolved with the specified value.

Parameters
<T>
The value type associated with the returned Promise.
value:T

The value of the resolved Promise.

Returns:Promise<T>

A new Promise which uses the default callback executor and default scheduled executor that has been resolved with the specified value.

See Also
PromiseFactory#resolved(Object)