Top Description Inners Fields Constructors Methods
org.osgi.util.promise

pack-priv final Class DeferredPromiseImpl<T>

extends PromiseImpl<T>
Class Inheritance
Type Parameters
<T>
The result type associated with the Promise.
Static Imports
java.util.Objects.requireNonNull

Deferred Promise implementation.

This class is not used directly by clients. Clients should use PromiseFactory#deferred() to create a Deferred which can be used to obtain a Promise whose resolution can be deferred.

Author
$Id: e8a864613a64516cae5de81c2f787f0d880c3e49 $
Since
1.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
DeferredPromiseImpl.Chain

A callback used to resolve the chained Promise when the Promise is resolved.

private class
DeferredPromiseImpl.ChainImpl

A callback used to resolve the chained Promise when the PromiseImpl is resolved.

pack-priv class
DeferredPromiseImpl.Delay

A callback used by the PromiseImpl#delay(long) method to delay chaining a promise.

private class
DeferredPromiseImpl.FallbackChain

A callback used to resolve the chained Promise when the fallback Promise is resolved.

pack-priv class
pack-priv class
pack-priv class
pack-priv class
DeferredPromiseImpl.Map<P>

A callback used by the PromiseImpl#map(Function) method.

pack-priv class
pack-priv class
private class
DeferredPromiseImpl.ResolveWith

A callback used to resolve a Promise with another Promise for the resolveWith(Promise) method or with another CompletionStage for the resolveWith(CompletionStage) method.

pack-priv class
pack-priv class
DeferredPromiseImpl.Then<P>

A callback used to chain promises for the PromiseImpl#then(Success, Failure) method.

pack-priv class
pack-priv class
DeferredPromiseImpl.Timeout

A callback used by the PromiseImpl#timeout(long) method to schedule the timeout and to resolve the chained Promise and cancel the timeout.

Field Summary

Modifier and TypeField and Description
private Throwable
fail

The failure of this Promise if resolved with a failure or null if successfully resolved.

private final CountDownLatch
resolved

A CountDownLatch to manage the resolved state of this Promise.

private T
value

The value of this Promise if successfully resolved.

Constructor Summary

AccessConstructor and Description
pack-priv
DeferredPromiseImpl(PromiseFactory
The factory to use for callbacks and scheduled operations.
factory
)

Initialize this Promise.

Method Summary

Modifier and TypeMethod and Description
public Throwable
getFailure()

Implements org.osgi.util.promise.Promise.getFailure.

Returns the failure of this Promise.

public T
getValue()

Implements org.osgi.util.promise.Promise.getValue.

Returns the value of this Promise.

public boolean
isDone()

Implements org.osgi.util.promise.Promise.isDone.

Returns whether this Promise has been resolved.

pack-priv PromiseImpl<T>

Returns:

A ResolvedPromiseImpl holding the value of this DeferredPromiseImpl or a FailedPromiseImpl holding the failure of this DeferredPromiseImpl or this DeferredPromiseImpl if this DeferredPromiseImpl is not resolved.
orDone
()

Return a resolved PromiseImpl if this DeferredPromiseImpl is resolved.

pack-priv void
resolve(T
The value of this Promise.
v
,
Throwable
The failure of this Promise.
f
)

Resolve this Promise.

pack-priv Promise<Void>

Returns:

A Promise that is resolved only when this Promise is resolved by the specified Promise. The returned Promise must be successfully resolved with the value null, if this Promise was resolved by the specified Promise. The returned Promise must be resolved with a failure of IllegalStateException, if this Promise was already resolved when the specified Promise was resolved.
resolveWith
(Promise<? extends T>
A Promise whose value or failure must be used to resolve this Promise. Must not be null.
with
)

Resolve this Promise with the specified Promise.

pack-priv Promise<Void>

Returns:

A Promise that is resolved only when this Promise is resolved by the specified CompletionStage. The returned Promise must be successfully resolved with the value null, if this Promise was resolved by the specified CompletionStage. The returned Promise must be resolved with a failure of IllegalStateException, if this Promise was already resolved when the specified CompletionStage was completed.
resolveWith
(CompletionStage<? extends T>
A CompletionStage whose result will be used to resolve this Promise. Must not be null.
with
)

Resolve this Promise with the specified CompletionStage.

pack-priv void
result(PromiseImpl.Result<? super T> consumer)

Implements abstract org.osgi.util.promise.PromiseImpl.result.

Accept the result of this PromiseImpl.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv boolean

Returns:

false if this Promise was already resolved; true if this method resolved this Promise.
tryResolve
(T
The value of this Promise.
v
,
Throwable
The failure of this Promise.
f
)

Try to resolve this Promise.

Inherited from org.osgi.util.promise.PromiseImpl:
deferreddelayexecutefailedfallbackTofallbackTofilterflatMapmapnotifyCallbacksonFailureonFailureonResolveonSuccessrecoverrecoverrecoverWithrecoverWithresolvedresultschedulethenthenthenAccepttimeouttoCompletionStageuncaughtException