Top Description Fields Constructors Methods
io.vertx.core.impl.future

pack-priv abstract Class FutureBase<T>

extends Object
implements FutureInternal<T>
Class Inheritance
All Implemented Interfaces
io.vertx.core.impl.future.FutureInternal, io.vertx.core.Future, io.vertx.core.AsyncResult
Known Direct Subclasses
io.vertx.core.impl.future.FutureImpl, io.vertx.core.impl.future.SucceededFuture, io.vertx.core.impl.future.FailedFuture
Imports
io.netty.util.concurrent.GlobalEventExecutor, .OrderedEventExecutor, .ScheduledFuture, io.vertx.core.AsyncResult, .Expectation, .Future, .Promise, io.vertx.core.impl.ContextInternal, .NoStackTraceTimeoutException, java.util.Objects, java.util.concurrent.TimeUnit, java.util.function.Function

Future base implementation.
Author
Julien Viet

Field Summary

Modifier and TypeField and Description
protected final ContextInternal

Constructor Summary

AccessConstructor and Description
pack-priv
FutureBase()

Create a future that hasn't completed yet

pack-priv
FutureBase(ContextInternal context)

Create a future that hasn't completed yet

Method Summary

Modifier and TypeMethod and Description
public <U> Future<U>
compose(Function<T, Future<U>>
the function mapping the success
successMapper
,
Function<Throwable, Future<U>>
the function mapping the failure
failureMapper
)

Implements io.vertx.core.Future.compose.

Compose this future with a successMapper and failureMapper functions.

public final ContextInternal
protected final void
emitFailure(Throwable cause, Listener<T> listener)

protected final void
emitSuccess(T value, Listener<T> listener)

public <U> Future<T>
eventually(Function<Void, Future<U>>
the function returning the future.
mapper
)

Implements io.vertx.core.Future.eventually.

Compose this future with a function that will be always be called.

public Future<T>
expecting(Expectation<? super T>
the expectation
expectation
)

Implements io.vertx.core.Future.expecting.

Guard the control flow of this future with an expectation.

public <U> Future<U>
map(Function<T, U>
the mapper function
mapper
)

Implements io.vertx.core.Future.map, io.vertx.core.Future.map.

Apply a mapper function on this future.

public <V> Future<V>
map(V
the value that eventually completes the mapped future
value
)

Implements io.vertx.core.Future.map.

Map the result of a future to a specific value.

public Future<T>
otherwise(Function<Throwable, T>
the mapper function
mapper
)

Implements io.vertx.core.Future.otherwise, io.vertx.core.Future.otherwise.

Apply a mapper function on this future.

public Future<T>
otherwise(T
the value that eventually completes the mapped future
value
)

Implements io.vertx.core.Future.otherwise.

Map the failure of a future to a specific value.

public Future<T>
timeout(long
the delay
delay
,
TimeUnit
the unit of the delay
unit
)

Implements io.vertx.core.Future.timeout.

Returns a future succeeded or failed with the outcome of this future when it happens before the timeout fires.

public <U> Future<U>
transform(Function<AsyncResult<T>, Future<U>>
the function mapping the future
mapper
)

Implements io.vertx.core.Future.transform.

Transform this future with a mapper functions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
protected final ContextInternal context

Constructor Detail

FutureBaseback to summary
pack-priv FutureBase()

Create a future that hasn't completed yet

FutureBaseback to summary
pack-priv FutureBase(ContextInternal context)

Create a future that hasn't completed yet

Method Detail

composeback to summary
public <U> Future<U> compose(Function<T, Future<U>> successMapper, Function<Throwable, Future<U>> failureMapper)

Implements io.vertx.core.Future.compose.

Doc from io.vertx.core.Future.compose.

Compose this future with a successMapper and failureMapper functions.

When this future (the one on which compose is called) succeeds, the successMapper will be called with the completed value and this mapper returns another future object. This returned future completion will complete the future returned by this method call.

When this future (the one on which compose is called) fails, the failureMapper will be called with the failure and this mapper returns another future object. This returned future completion will complete the future returned by this method call.

If any mapper function throws an exception, the returned future will be failed with this exception.

Parameters
successMapper:Function<T, Future<U>>

the function mapping the success

failureMapper:Function<Throwable, Future<U>>

the function mapping the failure

Returns:Future<U>

the composed future

Annotations
@Override
contextback to summary
public final ContextInternal context()

Implements io.vertx.core.impl.future.FutureInternal.context.

Returns:ContextInternal

Doc from io.vertx.core.impl.future.FutureInternal.context.

the context associated with this promise or null when there is none

emitFailureback to summary
protected final void emitFailure(Throwable cause, Listener<T> listener)
emitSuccessback to summary
protected final void emitSuccess(T value, Listener<T> listener)
eventuallyback to summary
public <U> Future<T> eventually(Function<Void, Future<U>> mapper)

Implements io.vertx.core.Future.eventually.

Doc from io.vertx.core.Future.eventually.

Compose this future with a function that will be always be called.

When this future (the one on which eventually is called) completes, the function will be called and this mapper returns another future object. This returned future completion will complete the future returned by this method call with the original result of the future.

The outcome of the future returned by the function will not influence the nature of the returned future.

Parameters
mapper:Function<Void, Future<U>>

the function returning the future.

Returns:Future<T>

the composed future

Annotations
@Override
expectingback to summary
public Future<T> expecting(Expectation<? super T> expectation)

Implements io.vertx.core.Future.expecting.

Doc from io.vertx.core.Future.expecting.

Guard the control flow of this future with an expectation.

When the future is completed with a success, the expectation is called with the result, when the expectation returns false the returned future is failed, otherwise the future is completed with the same result.

Expectations are usually lambda expressions:

return future.expecting(response -> response.statusCode() == 200);
Expectation instances can also be used:
future = future.expecting(HttpResponseExpectation.SC_OK);
Parameters
expectation:Expectation<? super T>

the expectation

Returns:Future<T>

a future succeeded with the result or failed when the expectation returns false

Annotations
@Override
mapback to summary
public <U> Future<U> map(Function<T, U> mapper)

Implements io.vertx.core.Future.map, io.vertx.core.Future.map.

Doc from io.vertx.core.Future.map.

Apply a mapper function on this future.

When this future succeeds, the mapper will be called with the completed value and this mapper returns a value. This value will complete the future returned by this method call.

If the mapper throws an exception, the returned future will be failed with this exception.

When this future fails, the failure will be propagated to the returned future and the mapper will not be called.

Parameters
mapper:Function<T, U>

the mapper function

Returns:Future<U>

the mapped future

Annotations
@Override
mapback to summary
public <V> Future<V> map(V value)

Implements io.vertx.core.Future.map.

Doc from io.vertx.core.Future.map.

Map the result of a future to a specific value.

When this future succeeds, this value will complete the future returned by this method call.

When this future fails, the failure will be propagated to the returned future.

Parameters
value:V

the value that eventually completes the mapped future

Returns:Future<V>

the mapped future

Annotations
@Override
otherwiseback to summary
public Future<T> otherwise(Function<Throwable, T> mapper)

Implements io.vertx.core.Future.otherwise, io.vertx.core.Future.otherwise.

Doc from io.vertx.core.Future.otherwise.

Apply a mapper function on this future.

When this future fails, the mapper will be called with the completed value and this mapper returns a value. This value will complete the future returned by this method call.

If the mapper throws an exception, the returned future will be failed with this exception.

When this future succeeds, the result will be propagated to the returned future and the mapper will not be called.

Parameters
mapper:Function<Throwable, T>

the mapper function

Returns:Future<T>

the mapped future

Annotations
@Override
otherwiseback to summary
public Future<T> otherwise(T value)

Implements io.vertx.core.Future.otherwise.

Doc from io.vertx.core.Future.otherwise.

Map the failure of a future to a specific value.

When this future fails, this value will complete the future returned by this method call.

When this future succeeds, the result will be propagated to the returned future.

Parameters
value:T

the value that eventually completes the mapped future

Returns:Future<T>

the mapped future

Annotations
@Override
timeoutback to summary
public Future<T> timeout(long delay, TimeUnit unit)

Implements io.vertx.core.Future.timeout.

Doc from io.vertx.core.Future.timeout.

Returns a future succeeded or failed with the outcome of this future when it happens before the timeout fires. When the timeout fires before, the future is failed with a java.util.concurrent.TimeoutException, guaranteeing the returned future to complete within the specified delay.

Parameters
delay:long

the delay

unit:TimeUnit

the unit of the delay

Returns:Future<T>

the timeout future

Annotations
@Override
transformback to summary
public <U> Future<U> transform(Function<AsyncResult<T>, Future<U>> mapper)

Implements io.vertx.core.Future.transform.

Doc from io.vertx.core.Future.transform.

Transform this future with a mapper functions.

When this future (the one on which transform is called) completes, the mapper will be called with the async result and this mapper returns another future object. This returned future completion will complete the future returned by this method call.

If any mapper function throws an exception, the returned future will be failed with this exception.

Parameters
mapper:Function<AsyncResult<T>, Future<U>>

the function mapping the future

Returns:Future<U>

the transformed future

Annotations
@Override