Promise base properties/methods. More...
Public Member Functions | |
boolean | castAndResolve (Object result) |
Casts the result and resolves the promise. More... | |
String | getId () |
Gets the identifier of this promise. More... | |
PromiseBase () | |
Initializes a new instance of the fm.liveswitch.PromiseBase class. More... | |
boolean | reject (java.lang.Exception exception) |
Rejects the promise. More... | |
fm.liveswitch.Future< Object > | rejectAsync (java.lang.Exception exception) |
Rejects the promise asynchronously. More... | |
boolean | resolve (T result) |
Resolves the promise. More... | |
fm.liveswitch.Future< Object > | resolveAsync (T result) |
Resolves the promise asynchronously. More... | |
Public Member Functions inherited from fm.liveswitch.Future< T > | |
abstract fm.liveswitch.Future< T > | fail (fm.liveswitch.IAction1< java.lang.Exception > rejectAction) |
Appends a handler to be executed when the promise is rejected. More... | |
abstract fm.liveswitch.Future< T > | fail (fm.liveswitch.IFunction1< java.lang.Exception, fm.liveswitch.Future< T >> rejectFunction) |
Appends a handler to be executed when the promise is rejected. More... | |
abstract fm.liveswitch.Future< T > | then (fm.liveswitch.IAction1< T > resolveAction) |
Appends a handler to be executed when the promise is resolved. More... | |
abstract fm.liveswitch.Future< T > | then (fm.liveswitch.IAction1< T > resolveAction, fm.liveswitch.IAction1< java.lang.Exception > rejectAction) |
Appends handlers to be executed when the promise is resolved or rejected. More... | |
abstract< R extends Object > fm.liveswitch.Future< R > | then (fm.liveswitch.IFunction1< T, fm.liveswitch.Future< R >> resolveFunction) |
Appends a handler to be executed when the promise is resolved. More... | |
abstract< R extends Object > fm.liveswitch.Future< R > | then (fm.liveswitch.IFunction1< T, fm.liveswitch.Future< R >> resolveFunction, fm.liveswitch.IAction1< java.lang.Exception > rejectAction) |
Appends handlers to be executed when the promise is resolved or rejected. More... | |
void | waitForPromise () |
Blocks the current thread from proceeding until the future state has been resolved or rejected. More... | |
void | waitForPromise (int millisecondsTimeout) |
Blocks the current thread from proceeding until the future state has been resolved or rejected or if the timeout period elapses. More... | |
T | waitForResult () |
Blocks the current thread from proceeding until the future has a result. More... | |
T | waitForResult (int millisecondsTimeout) |
Blocks the current thread from proceeding until the future has a result. More... | |
Public Member Functions inherited from fm.liveswitch.FutureBase< T > | |
java.lang.Exception | getException () |
Gets the exception if rejected. More... | |
T | getResult () |
Gets the result if resolved. More... | |
fm.liveswitch.FutureState | getState () |
Gets the current state. More... | |
Static Public Member Functions | |
static< R extends Object > fm.liveswitch.Future< R > | all (fm.liveswitch.Future< R >[] promises) |
Returns a promise that resolves when all passed in promises resolve. More... | |
static< R extends Object > fm.liveswitch.Future< R > | any (fm.liveswitch.Future< R >[] promises) |
Returns a promise that resolves when any passed in promise resolves. More... | |
static< R extends Object > fm.liveswitch.Future< R > | delay (int delayMs) |
Create a promise that resolves afer a delay. More... | |
static< R extends Object > fm.liveswitch.Future< R > | rejectNow (java.lang.Exception ex) |
Creates a promise and rejects it immediately. More... | |
static fm.liveswitch.Future< Object > | resolveNow () |
Creates a promise and resolves it immediately using a null result value. More... | |
static< R extends Object > fm.liveswitch.Future< R > | resolveNow (R result) |
Creates a promise and resolves it immediately using the given result value. More... | |
static< R extends Object > fm.liveswitch.Future< R > | wrapPromise (fm.liveswitch.IFunction0< fm.liveswitch.Future< R >> callback) |
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown. More... | |
Protected Member Functions | |
void | process (fm.liveswitch.IPromise promise, fm.liveswitch.IAction1< T > resolve, fm.liveswitch.IAction1< java.lang.Exception > reject) |
Processes the specified promise. More... | |
Protected Member Functions inherited from fm.liveswitch.Future< T > | |
Future () | |
Protected Member Functions inherited from fm.liveswitch.FutureBase< T > | |
FutureBase () | |
void | setException (java.lang.Exception value) |
Sets the exception if rejected. More... | |
void | setResult (T value) |
Sets the result if resolved. More... | |
void | setState (fm.liveswitch.FutureState value) |
Sets the current state. More... | |
Promise base properties/methods.
fm.liveswitch.PromiseBase< T >.PromiseBase | ( | ) |
Initializes a new instance of the fm.liveswitch.PromiseBase class.
|
static |
Returns a promise that resolves when all passed in promises resolve.
promises | The promises to check. |
|
static |
Returns a promise that resolves when any passed in promise resolves.
promises | The promises to check. |
boolean fm.liveswitch.PromiseBase< T >.castAndResolve | ( | Object | result | ) |
Casts the result and resolves the promise.
Will throw an exception if the cast fails.
result | The result. |
Implements fm.liveswitch.IPromise.
|
static |
Create a promise that resolves afer a delay.
delayMs |
String fm.liveswitch.PromiseBase< T >.getId | ( | ) |
Gets the identifier of this promise.
|
protected |
Processes the specified promise.
promise | The promise. |
resolve | The resolve. |
reject | The reject. |
boolean fm.liveswitch.PromiseBase< T >.reject | ( | java.lang.Exception | exception | ) |
fm.liveswitch.Future<Object> fm.liveswitch.PromiseBase< T >.rejectAsync | ( | java.lang.Exception | exception | ) |
Rejects the promise asynchronously.
exception | The exception. |
|
static |
Creates a promise and rejects it immediately.
ex | The exception. |
boolean fm.liveswitch.PromiseBase< T >.resolve | ( | T | result | ) |
Resolves the promise.
result | The result. |
fm.liveswitch.Future<Object> fm.liveswitch.PromiseBase< T >.resolveAsync | ( | T | result | ) |
Resolves the promise asynchronously.
result | The result. |
|
static |
Creates a promise and resolves it immediately using a null result value.
|
static |
Creates a promise and resolves it immediately using the given result value.
result | The result. |
|
static |
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown.
callback | The callback function. |