Package org.dataloader.impl
Class PromisedValuesImpl<T>
- java.lang.Object
-
- org.dataloader.impl.PromisedValuesImpl<T>
-
- All Implemented Interfaces:
PromisedValues<T>
public class PromisedValuesImpl<T> extends java.lang.Object implements PromisedValues<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Throwable
cause()
The exception cause or null if it didn't failjava.lang.Throwable
cause(int index)
The exception cause at the specified index or null if it didn't failstatic <T> PromisedValues<T>
combineAllOf(java.util.List<? extends java.util.concurrent.CompletionStage<T>> cfs)
static <T> PromisedValues<T>
combinePromisedValues(java.util.List<PromisedValues<T>> promisedValues)
boolean
failed()
T
get(int index)
The value at index or null if it failedboolean
isDone()
The true if the all the futures have completed (and hence thisPromisedValues
has completed)java.util.List<T>
join()
Waits for the underlying futures to complete.int
size()
boolean
succeeded()
boolean
succeeded(int index)
The true if theCompletionStage
at the specified index succeededPromisedValues<T>
thenAccept(java.util.function.Consumer<PromisedValues<T>> handler)
When the all the futures complete, this call back will be invoked with thisPromisedValues
as a parameterjava.util.concurrent.CompletableFuture<java.util.List<T>>
toCompletableFuture()
java.util.List<T>
toList()
Returns the underlying values as a list
-
-
-
Method Detail
-
combineAllOf
public static <T> PromisedValues<T> combineAllOf(java.util.List<? extends java.util.concurrent.CompletionStage<T>> cfs)
-
combinePromisedValues
public static <T> PromisedValues<T> combinePromisedValues(java.util.List<PromisedValues<T>> promisedValues)
-
thenAccept
public PromisedValues<T> thenAccept(java.util.function.Consumer<PromisedValues<T>> handler)
Description copied from interface:PromisedValues
When the all the futures complete, this call back will be invoked with thisPromisedValues
as a parameter- Specified by:
thenAccept
in interfacePromisedValues<T>
- Parameters:
handler
- the call back which will be given this object- Returns:
- a new
PromisedValues
which you can compose more computations with
-
succeeded
public boolean succeeded()
- Specified by:
succeeded
in interfacePromisedValues<T>
- Returns:
- true if all the futures completed successfully
-
failed
public boolean failed()
- Specified by:
failed
in interfacePromisedValues<T>
- Returns:
- true if any of the futures completed unsuccessfully
-
isDone
public boolean isDone()
Description copied from interface:PromisedValues
The true if the all the futures have completed (and hence thisPromisedValues
has completed)- Specified by:
isDone
in interfacePromisedValues<T>
- Returns:
- true if all the futures have completed
-
cause
public java.lang.Throwable cause()
Description copied from interface:PromisedValues
The exception cause or null if it didn't fail- Specified by:
cause
in interfacePromisedValues<T>
- Returns:
- an exception or null if the future did not fail
-
succeeded
public boolean succeeded(int index)
Description copied from interface:PromisedValues
The true if theCompletionStage
at the specified index succeeded- Specified by:
succeeded
in interfacePromisedValues<T>
- Parameters:
index
- the index of theCompletionStage
- Returns:
- true if the future at the specified index succeeded
-
cause
public java.lang.Throwable cause(int index)
Description copied from interface:PromisedValues
The exception cause at the specified index or null if it didn't fail- Specified by:
cause
in interfacePromisedValues<T>
- Parameters:
index
- the index of theCompletionStage
- Returns:
- an exception or null if the future did not fail
-
get
public T get(int index)
Description copied from interface:PromisedValues
The value at index or null if it failed- Specified by:
get
in interfacePromisedValues<T>
- Parameters:
index
- the index of the future- Returns:
- the value of the future
-
toList
public java.util.List<T> toList()
Description copied from interface:PromisedValues
Returns the underlying values as a list- Specified by:
toList
in interfacePromisedValues<T>
- Returns:
- the list of underlying values
-
size
public int size()
- Specified by:
size
in interfacePromisedValues<T>
- Returns:
- the number of
CompletionStage
s under the covers
-
join
public java.util.List<T> join()
Description copied from interface:PromisedValues
Waits for the underlying futures to complete. To better conform with the use of common functional forms, if a computation involved in the completion of this CompletableFuture threw an exception, this method throws an (unchecked)CompletionException
with the underlying exception as its cause.- Specified by:
join
in interfacePromisedValues<T>
- Returns:
- the list of completed values similar to
PromisedValues.toList()
-
toCompletableFuture
public java.util.concurrent.CompletableFuture<java.util.List<T>> toCompletableFuture()
- Specified by:
toCompletableFuture
in interfacePromisedValues<T>
- Returns:
- this as a
CompletableFuture
that returns the list of underlying values
-
-