public interface IFuture<E>
Modifier and Type | Field and Description |
---|---|
static IFuture<java.lang.Void> |
DONE
A future representing a completed action.
|
static IFuture<java.lang.Boolean> |
FALSE
A future representing a false result.
|
static IFuture<java.lang.Boolean> |
TRUE
A future representing a true result.
|
Modifier and Type | Method and Description |
---|---|
IFuture<java.lang.Void> |
acceptEither(IFuture<E> other,
Consumer<E> action,
java.lang.Class<?> futuretype)
The given consumer will be executed with either of the result of this and the given other future.
|
void |
addResultListener(IFunctionalResultListener<E> listener)
Add an functional result listener, which is only called on success.
|
void |
addResultListener(IFunctionalResultListener<E> sucListener,
IFunctionalExceptionListener exListener)
Add a result listener by combining an OnSuccessListener and an
OnExceptionListener.
|
void |
addResultListener(IResultListener<E> listener)
Add a result listener.
|
<U> IFuture<U> |
applyToEither(IFuture<E> other,
Function<E,U> fn,
java.lang.Class<?> futuretype)
The given function will be executed with either of the result of this and the given other future.
|
E |
get()
Get the result - blocking call.
|
E |
get(long timeout)
Get the result - blocking call.
|
E |
get(ThreadSuspendable sus)
Deprecated.
- From 3.0. Use the version without suspendable.
Will NOT use the suspendable given as parameter.
Get the result - blocking call.
|
java.lang.Exception |
getException()
Get the exception, if any.
|
boolean |
isDone()
Test if done, i.e.
|
IFuture<java.lang.Void> |
thenAccept(Consumer<? super E> consumer)
Applies a synchronous function consuming the result after it is available.
|
IFuture<java.lang.Void> |
thenAccept(Consumer<? super E> consumer,
java.lang.Class<?> futuretype)
Applies a function consuming the result after it is available.
|
<T> IFuture<T> |
thenApply(Function<? super E,? extends T> function)
Applies a function after the result is available, using the result of this Future as input.
|
<T> IFuture<T> |
thenApply(Function<? super E,? extends T> function,
java.lang.Class<?> futuretype)
Applies a function after the result is available, using the result of this Future as input.
|
<U,V> IFuture<V> |
thenCombine(IFuture<U> other,
BiFunction<? super E,? super U,? extends V> function,
java.lang.Class<?> futuretype)
Combines this and another future and uses the given bifunction to calculate the result.
|
<T> IFuture<T> |
thenCompose(Function<? super E,IFuture<T>> function)
The result of this future is delegated to the given (future-returning) function.
|
<T> IFuture<T> |
thenCompose(Function<? super E,IFuture<T>> function,
java.lang.Class<?> futuretype)
The result of this future is delegated to the given (future-returning) function.
|
static final IFuture<java.lang.Void> DONE
static final IFuture<java.lang.Boolean> TRUE
static final IFuture<java.lang.Boolean> FALSE
boolean isDone()
java.lang.Exception getException()
E get()
E get(long timeout)
timeout
- The timeout in millis.E get(ThreadSuspendable sus)
void addResultListener(IResultListener<E> listener)
listener
- The listener.void addResultListener(IFunctionalResultListener<E> listener)
listener
- The listener.void addResultListener(IFunctionalResultListener<E> sucListener, IFunctionalExceptionListener exListener)
sucListener
- The listener that is called on success.exListener
- The listener that is called on exceptions. Passing
null
enables default exception logging.<T> IFuture<T> thenApply(Function<? super E,? extends T> function)
function
- Function that takes the result of this future as input and delivers t.<T> IFuture<T> thenApply(Function<? super E,? extends T> function, java.lang.Class<?> futuretype)
function
- Function that takes the result of this future as input and delivers t.futuretype
- The type of the return future.<T> IFuture<T> thenCompose(Function<? super E,IFuture<T>> function)
function
- Function that takes the result of this future as input and delivers future(t).<T> IFuture<T> thenCompose(Function<? super E,IFuture<T>> function, java.lang.Class<?> futuretype)
function
- Function that takes the result of this future as input and delivers future(t).futuretype
- The type of the return future. If null, a default future is created.IFuture<java.lang.Void> thenAccept(Consumer<? super E> consumer)
consumer
- Consumer that takes the result of this future as input and consumes it.IFuture<java.lang.Void> thenAccept(Consumer<? super E> consumer, java.lang.Class<?> futuretype)
consumer
- Consumer that takes the result of this future as input and consumes it.futuretype
- The type of the return future. If null, a default future is created.<U,V> IFuture<V> thenCombine(IFuture<U> other, BiFunction<? super E,? super U,? extends V> function, java.lang.Class<?> futuretype)
function
- BiFunction that takes the result of this and given other future as input and produces output.futuretype
- The type of the return future. If null, a default future is created.<U> IFuture<U> applyToEither(IFuture<E> other, Function<E,U> fn, java.lang.Class<?> futuretype)
other
- other futurefn
- function to receive resultfuturetype
- The type of the return future. If null, a default future is created.IFuture<java.lang.Void> acceptEither(IFuture<E> other, Consumer<E> action, java.lang.Class<?> futuretype)
other
- other futurefn
- function to receive resultfuturetype
- The type of the return future. If null, a default future is created.