Package io.joynr.provider
Class AbstractDeferred
- java.lang.Object
-
- io.joynr.provider.AbstractDeferred
-
- Direct Known Subclasses:
AccessControlListEditorProvider.RemoveMasterAccessControlEntryDeferred,AccessControlListEditorProvider.RemoveMasterRegistrationControlEntryDeferred,AccessControlListEditorProvider.RemoveMediatorAccessControlEntryDeferred,AccessControlListEditorProvider.RemoveMediatorRegistrationControlEntryDeferred,AccessControlListEditorProvider.RemoveOwnerAccessControlEntryDeferred,AccessControlListEditorProvider.RemoveOwnerRegistrationControlEntryDeferred,AccessControlListEditorProvider.UpdateMasterAccessControlEntryDeferred,AccessControlListEditorProvider.UpdateMasterRegistrationControlEntryDeferred,AccessControlListEditorProvider.UpdateMediatorAccessControlEntryDeferred,AccessControlListEditorProvider.UpdateMediatorRegistrationControlEntryDeferred,AccessControlListEditorProvider.UpdateOwnerAccessControlEntryDeferred,AccessControlListEditorProvider.UpdateOwnerRegistrationControlEntryDeferred,Deferred,DeferredVoid,DiscoveryProvider.Add1Deferred,DiscoveryProvider.AddToAllDeferred,DiscoveryProvider.Lookup1Deferred,DiscoveryProvider.Lookup2Deferred,DiscoveryProvider.Lookup3Deferred,DiscoveryProvider.Lookup4Deferred,GlobalCapabilitiesDirectoryProvider.Add1Deferred,GlobalCapabilitiesDirectoryProvider.Lookup1Deferred,GlobalCapabilitiesDirectoryProvider.Lookup2Deferred,GlobalCapabilitiesDirectoryProvider.Lookup3Deferred,GlobalCapabilitiesDirectoryProvider.Lookup4Deferred,GlobalCapabilitiesDirectoryProvider.Remove1Deferred,MultiValueDeferred,RoutingProvider.ResolveNextHopDeferred
public abstract class AbstractDeferred extends Object
-
-
Constructor Summary
Constructors Constructor Description AbstractDeferred()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(DeferredListener listener)Adds a listener that is called once the deferred is settled.Optional<JoynrException>getError()Optional<Object[]>getValues()booleanisFulfilled()booleanisRejected()booleanisSettled()protected booleanreject(JoynrException error)Rejects the promise.booleanreject(ProviderRuntimeException error)Rejects the promise.protected booleanresolve(Object... values)Resolves the promise.
-
-
-
Method Detail
-
resolve
protected boolean resolve(Object... values)
Resolves the promise. NOTE: The thread resolving the promise will be used to execute waiting listeners.- Parameters:
values- the result which resolves the Deferred.- Returns:
- true if the promise is resolved; false in case the promise is already settled.
-
reject
protected boolean reject(JoynrException error)
Rejects the promise. NOTE: The thread rejecting the promise will be used to execute waiting listeners.- Parameters:
error- the reason that caused the rejection.- Returns:
- true if the promise is rejected; false in case the promise is already settled.
-
reject
public boolean reject(ProviderRuntimeException error)
Rejects the promise. NOTE: The thread rejecting the promise will be used to execute waiting listeners.- Parameters:
error- the reason that caused the rejection.- Returns:
- true if the promise is rejected; false in case the promise is already settled.
-
getError
public Optional<JoynrException> getError()
- Returns:
- the error that caused the rejection of the deferred; null if the deferred is not in rejected state.
-
getValues
public Optional<Object[]> getValues()
- Returns:
- the values that caused the fulfillment of the deferred; null if the deferred is not in fulfilled state.
-
addListener
public void addListener(DeferredListener listener)
Adds a listener that is called once the deferred is settled. NOTE: If the deferred is already settled when adding the listener, the thread adding the listener will be used to execute the listener.- Parameters:
listener- the listener to add.
-
isFulfilled
public boolean isFulfilled()
-
isRejected
public boolean isRejected()
-
isSettled
public boolean isSettled()
- Returns:
- true if the promise is fulfilled or rejected; false if the promise is pending.
-
-