Class ClosingFuture.Combiner4<V1,V2,V3,V4>
- Type Parameters:
V1- the type returned by the first futureV2- the type returned by the second futureV3- the type returned by the third futureV4- the type returned by the fourth future
- Enclosing class:
ClosingFuture<V>
ClosingFuture.Combiner that lets you use a lambda or method reference to combine four
ClosingFutures. Use ClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture) to start this combination.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA function that returns aClosingFuturewhen applied to the values of the four futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture).static interfaceA function that returns a value when applied to the values of the four futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture).Nested classes/interfaces inherited from class com.google.common.util.concurrent.ClosingFuture.Combiner
ClosingFuture.Combiner.AsyncCombiningCallable<V>, ClosingFuture.Combiner.CombiningCallable<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClosingFuture<V1> private final ClosingFuture<V2> private final ClosingFuture<V3> private final ClosingFuture<V4> Fields inherited from class com.google.common.util.concurrent.ClosingFuture.Combiner
inputs -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCombiner4(ClosingFuture<V1> future1, ClosingFuture<V2> future2, ClosingFuture<V3> future3, ClosingFuture<V4> future4) -
Method Summary
Modifier and TypeMethodDescription<U> ClosingFuture<U> Returns a newClosingFuturepipeline step derived from the inputs by applying a combining function to their values.<U> ClosingFuture<U> Returns a newClosingFuturepipeline step derived from the inputs by applying aClosingFuture-returning function to their values.Methods inherited from class com.google.common.util.concurrent.ClosingFuture.Combiner
call, callAsync
-
Field Details
-
future1
-
future2
-
future3
-
future4
-
-
Constructor Details
-
Combiner4
private Combiner4(ClosingFuture<V1> future1, ClosingFuture<V2> future2, ClosingFuture<V3> future3, ClosingFuture<V4> future4)
-
-
Method Details
-
call
public <U> ClosingFuture<U> call(ClosingFuture.Combiner4.ClosingFunction4<V1, V2, V3, V4, U> function, Executor executor) Returns a newClosingFuturepipeline step derived from the inputs by applying a combining function to their values. The function can use aClosingFuture.DeferredCloserto capture objects to be closed when the pipeline is done.If this combiner was returned by
ClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture)and any of the inputs fail, so will the returned step.If the function throws a
CancellationException, the pipeline will be cancelled.If the function throws an
ExecutionException, the cause of the thrownExecutionExceptionwill be extracted and used as the failure of the derived step. -
callAsync
public <U> ClosingFuture<U> callAsync(ClosingFuture.Combiner4.AsyncClosingFunction4<V1, V2, V3, V4, U> function, Executor executor) Returns a newClosingFuturepipeline step derived from the inputs by applying aClosingFuture-returning function to their values. The function can use aClosingFuture.DeferredCloserto capture objects to be closed when the pipeline is done (other than those captured by the returnedClosingFuture).If this combiner was returned by
ClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture)and any of the inputs fail, so will the returned step.If the function throws a
CancellationException, the pipeline will be cancelled.If the function throws an
ExecutionException, the cause of the thrownExecutionExceptionwill be extracted and used as the failure of the derived step.If the function throws any other exception, it will be used as the failure of the derived step.
If an exception is thrown after the function creates a
ClosingFuture, then none of the closeable objects in thatClosingFuturewill be closed.Usage guidelines for this method:
- Use this method only when calling an API that returns a
ListenableFutureor aClosingFuture. If possible, prefer callingClosingFuture.Combiner.call(CombiningCallable, Executor)instead, with a function that returns the next value directly. - Call
closer.eventuallyClose()for every closeable object this step creates in order to capture it for later closing. - Return a
ClosingFuture. To turn aListenableFutureinto aClosingFuturecallClosingFuture.from(ListenableFuture).
The same warnings about doing heavyweight operations within
ClosingFuture.transformAsync(AsyncClosingFunction, Executor)apply here. - Use this method only when calling an API that returns a
-