Package io.joynr.provider
Class PromiseKeeper
- java.lang.Object
-
- io.joynr.provider.PromiseKeeper
-
- All Implemented Interfaces:
PromiseListener
public class PromiseKeeper extends Object implements PromiseListener
-
-
Constructor Summary
Constructors Constructor Description PromiseKeeper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<JoynrException>getError()Get the error causing rejection of the promise.Optional<JoynrException>getError(long timeout)Get the error causing rejection of the promise.Optional<Object[]>getValues()Get the resolved values of the promise.Optional<Object[]>getValues(long timeout)Get the resolved values of the promise.booleanisFulfilled()booleanisRejected()booleanisSettled()voidonFulfillment(Object... values)voidonRejection(JoynrException error)voidwaitForSettlement()Blocks until the promise is settled.voidwaitForSettlement(long timeout)Blocks until the promise is settled or timeout is reached.
-
-
-
Method Detail
-
onFulfillment
public void onFulfillment(Object... values)
- Specified by:
onFulfillmentin interfacePromiseListener
-
onRejection
public void onRejection(JoynrException error)
- Specified by:
onRejectionin interfacePromiseListener
-
getValues
public Optional<Object[]> getValues() throws InterruptedException
Get the resolved values of the promise. If the promise is not settled, the call blocks until the promise is settled.- Returns:
- the resolved values or null in case of timeout.
- Throws:
InterruptedException- if the thread is interrupted.
-
getValues
public Optional<Object[]> getValues(long timeout) throws InterruptedException
Get the resolved values of the promise. If the promise is not settled, the call blocks until the promise is settled or timeout is reached.- Parameters:
timeout- the maximum time to wait in milliseconds.- Returns:
- the resolved values or null in case of timeout.
- Throws:
InterruptedException- if the thread is interrupted.
-
getError
public Optional<JoynrException> getError() throws InterruptedException
Get the error causing rejection of the promise. If the promise is not settled, the call blocks until the promise is settled.- Returns:
- the error causing rejection or null in case of timeout.
- Throws:
InterruptedException- if the thread is interrupted.
-
getError
public Optional<JoynrException> getError(long timeout) throws InterruptedException
Get the error causing rejection of the promise. If the promise is not settled, the call blocks until the promise is settled or timeout is reached.- Parameters:
timeout- the maximum time to wait in milliseconds.- Returns:
- the error causing rejection or null in case of timeout.
- Throws:
InterruptedException- if the thread is interrupted.
-
waitForSettlement
public void waitForSettlement() throws InterruptedExceptionBlocks until the promise is settled.- Throws:
InterruptedException- if the thread is interrupted.
-
waitForSettlement
public void waitForSettlement(long timeout) throws InterruptedExceptionBlocks until the promise is settled or timeout is reached.- Parameters:
timeout- the maximum time to wait in milliseconds.- Throws:
InterruptedException- if the thread is interrupted.
-
isFulfilled
public boolean isFulfilled()
-
isRejected
public boolean isRejected()
-
isSettled
public boolean isSettled()
-
-