@Override public <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper, Executor executor, ListenerOptimizationStrategy optimizeExecution) { return InternalFutureUtils.flatTransform(this, this::getCancellationExceptionMessage, mapper, executor, optimizeExecution); }
@Override public <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper, Executor executor) { return InternalFutureUtils.flatTransform(this, this::getCancellationExceptionMessage, mapper, executor, null); }
@Override public <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper) { return InternalFutureUtils.flatTransform(this, this::getCancellationExceptionMessage, mapper, null, null); }
@Override public <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper, Executor executor, ListenerOptimizationStrategy optimizeExecution) { return InternalFutureUtils.flatTransform(this, this::getCancellationExceptionMessage, mapper, executor, optimizeExecution); }
@Override public <R> ListenableFuture<R> flatMap(ListenableFuture<R> future) { return InternalFutureUtils.flatTransform(this, this::getCancellationExceptionMessage, (ignored) -> future, null, null); }
@Override public <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper, Executor executor) { return InternalFutureUtils.flatTransform(this, this::getCancellationExceptionMessage, mapper, executor, null); }
@Override public <R> ListenableFuture<R> flatMap(ListenableFuture<R> future) { return InternalFutureUtils.flatTransform(this, this::getCancellationExceptionMessage, (ignored) -> future, null, null); }
@Override public <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper) { return InternalFutureUtils.flatTransform(this, this::getCancellationExceptionMessage, mapper, null, null); }
/** * Convenience function for mapping this future in with an existing future, ignoring the result * of this current future. This is equivalent to {@code flatMap((ignored) -> future)}, and * conceptually the same as {@link FutureUtils#makeFailurePropagatingCompleteFuture(Iterable)} * with both futures being provided (though this allows us to capture the result of the provided * future). * <p> * Please be aware that {@code flatMap(futureProducer.get())} is NOT equivalent to * {@code flatMap((ignored) -> futureProducer.get())}. As the second version would delay starting * the future generation until this future completes. By calling into this with a future you will * be starting its execution immediately. * * @param <R> The type of result returned from the provided future * @param future The future to flat mpa against this one * @return A new {@link ListenableFuture} that will complete when both this and the provided future does */ default <R> ListenableFuture<R> flatMap(ListenableFuture<R> future) { return InternalFutureUtils.flatTransform(this, null, (ignored) -> future, null, null); }
/** * Convenience function for mapping this future in with an existing future, ignoring the result * of this current future. This is equivalent to {@code flatMap((ignored) -> future)}, and * conceptually the same as {@link FutureUtils#makeFailurePropagatingCompleteFuture(Iterable)} * with both futures being provided (though this allows us to capture the result of the provided * future). * <p> * Please be aware that {@code flatMap(futureProducer.get())} is NOT equivalent to * {@code flatMap((ignored) -> futureProducer.get())}. As the second version would delay starting * the future generation until this future completes. By calling into this with a future you will * be starting its execution immediately. * * @param <R> The type of result returned from the provided future * @param future The future to flat mpa against this one * @return A new {@link ListenableFuture} that will complete when both this and the provided future does */ default <R> ListenableFuture<R> flatMap(ListenableFuture<R> future) { return InternalFutureUtils.flatTransform(this, null, (ignored) -> future, null, null); }
/** * Similar to {@link #map(Function, Executor)}, in that this will apply a mapper function once * the applied to future completes. Once this future resolves it will provide the result into * the provided function. Unlike {@link #map(Function, Executor)}, this will then unwrap a * future provided from the function so that instead of having * {@code ListenableFuture<ListenableFuture<R>>} you can simply extract the final value. The * returned future will only resolve once the future of the provided function completes. * <p> * Once the future completes the mapper function will be invoked on the executor (if provided). * Because of that providing an executor can ensure this will never block. If an executor is * not provided then the mapper may be invoked on the calling thread (if the future is already * complete), or on the same thread which the future completes on. If the mapper function is * very fast and cheap to run then {@link #flatMap(Function)} or providing {@code null} for the * executor can allow more efficient operation. * * @since 5.0 * @param <R> The type for the object contained in the future which is returned from the mapper * @param mapper Function to invoke in order to transform the futures result * @param executor Executor to invoke mapper function on, or {@code null} * to invoke on this thread or future complete thread (depending on future state) * @return A new {@link ListenableFuture} with the specified result type */ default <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper, Executor executor) { return InternalFutureUtils.flatTransform(this, null, mapper, executor, null); }
/** * Similar to {@link #map(Function, Executor)}, in that this will apply a mapper function once * the applied to future completes. Once this future resolves it will provide the result into * the provided function. Unlike {@link #map(Function, Executor)}, this will then unwrap a * future provided from the function so that instead of having * {@code ListenableFuture<ListenableFuture<R>>} you can simply extract the final value. The * returned future will only resolve once the future of the provided function completes. * <p> * Once the future completes the mapper function will be invoked on the executor (if provided). * Because of that providing an executor can ensure this will never block. If an executor is * not provided then the mapper may be invoked on the calling thread (if the future is already * complete), or on the same thread which the future completes on. If the mapper function is * very fast and cheap to run then {@link #flatMap(Function)} or providing {@code null} for the * executor can allow more efficient operation. * * @since 5.0 * @param <R> The type for the object contained in the future which is returned from the mapper * @param mapper Function to invoke in order to transform the futures result * @param executor Executor to invoke mapper function on, or {@code null} * to invoke on this thread or future complete thread (depending on future state) * @return A new {@link ListenableFuture} with the specified result type */ default <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper, Executor executor) { return InternalFutureUtils.flatTransform(this, null, mapper, executor, null); }
/** * Similar to {@link #map(Function)}, in that this will apply a mapper function once the applied * to future completes. Once this future resolves it will provide the result into the provided * function. Unlike {@link #map(Function)}, this will then unwrap a future provided from the * function so that instead of having {@code ListenableFuture<ListenableFuture<R>>} you can * simply extract the final value. The returned future will only resolve once the future of the * provided function completes. * <p> * If the future is complete already, the function may be invoked on the invoking thread. If the * future is not complete then the function will be invoked on the thread which completes * the future (immediately after it completes). * <p> * Example use: * <pre>{@code * public ListenableFuture<Integer> countSomething(String value); * * public ListenableFuture<String> lookupSomething(); * * ListenableFuture<Integer> count = lookupSomething().flatMap((s) -> countSomething(s)); * }</pre> * * @since 5.0 * @param <R> The type for the object contained in the future which is returned from the mapper * @param mapper Function to invoke in order to transform the futures result * @return A new {@link ListenableFuture} with the specified result type */ default <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper) { return InternalFutureUtils.flatTransform(this, null, mapper, null, null); }
/** * Similar to {@link #map(Function)}, in that this will apply a mapper function once the applied * to future completes. Once this future resolves it will provide the result into the provided * function. Unlike {@link #map(Function)}, this will then unwrap a future provided from the * function so that instead of having {@code ListenableFuture<ListenableFuture<R>>} you can * simply extract the final value. The returned future will only resolve once the future of the * provided function completes. * <p> * If the future is complete already, the function may be invoked on the invoking thread. If the * future is not complete then the function will be invoked on the thread which completes * the future (immediately after it completes). * <p> * Example use: * <pre>{@code * public ListenableFuture<Integer> countSomething(String value); * * public ListenableFuture<String> lookupSomething(); * * ListenableFuture<Integer> count = lookupSomething().flatMap((s) -> countSomething(s)); * }</pre> * * @since 5.0 * @param <R> The type for the object contained in the future which is returned from the mapper * @param mapper Function to invoke in order to transform the futures result * @return A new {@link ListenableFuture} with the specified result type */ default <R> ListenableFuture<R> flatMap(Function<? super T, ListenableFuture<R>> mapper) { return InternalFutureUtils.flatTransform(this, null, mapper, null, null); }
Executor executor, ListenerOptimizationStrategy optimizeExecution) { return InternalFutureUtils.flatTransform(this, null, mapper, executor, optimizeExecution);
Executor executor, ListenerOptimizationStrategy optimizeExecution) { return InternalFutureUtils.flatTransform(this, null, mapper, executor, optimizeExecution);