Package graphql.execution
Class Async
java.lang.Object
graphql.execution.Async
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA builder of materialized objects orCompletableFutures than can present a promise to the list of them -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,U> CompletableFuture <List<U>> each(Collection<T> list, Function<T, Object> cfOrMaterialisedValueFactory) static <T> ObjecteachPolymorphic(Collection<T> list, Function<T, Object> cfOrMaterialisedValueFactory) This will run the value factory for each of the values in the provided list.static <T,U> CompletableFuture <List<U>> eachSequentially(Iterable<T> list, BiFunction<T, List<U>, Object> cfOrMaterialisedValueFactory) static <T> CompletableFuture<T> exceptionallyCompletedFuture(Throwable exception) static <T> Async.CombinedBuilder<T> ofExpectedSize(int expectedSize) Combines zero or more CFs into one.static <T> @NonNull CompletableFuture<T> orNullCompletedFuture(@Nullable CompletableFuture<T> completableFuture) If the passed in CompletableFuture is null, then it creates a CompletableFuture that resolves to nullstatic <T> CompletableFuture<T> Turns an object T into a CompletableFuture if it's not alreadystatic ObjectTurns a CompletionStage into a CompletableFuture if it's not already, otherwise leaves it alone as a materialized object.static <T> CompletableFuture<T> tryCatch(Supplier<CompletableFuture<T>> supplier)
-
Constructor Details
-
Async
public Async()
-
-
Method Details
-
ofExpectedSize
Combines zero or more CFs into one. It is a wrapper aroundCompletableFuture.allOf.- Type Parameters:
T- for two- Parameters:
expectedSize- how many we expect- Returns:
- a combined builder of CFs
-
each
public static <T,U> CompletableFuture<List<U>> each(Collection<T> list, Function<T, Object> cfOrMaterialisedValueFactory) -
eachPolymorphic
public static <T> Object eachPolymorphic(Collection<T> list, Function<T, Object> cfOrMaterialisedValueFactory) This will run the value factory for each of the values in the provided list.If any of the values provided is a
CompletableFutureit will return aCompletableFutureresult object that joins on all values otherwise if none of the values are aCompletableFuturethen it will return a materialized list.- Type Parameters:
T- for two- Parameters:
list- the list to work overcfOrMaterialisedValueFactory- the value factory to call for each iterm in the list- Returns:
- a
CompletableFutureto the list of resolved values or the list of values in a materialized fashion
-
eachSequentially
public static <T,U> CompletableFuture<List<U>> eachSequentially(Iterable<T> list, BiFunction<T, List<U>, Object> cfOrMaterialisedValueFactory) -
toCompletableFuture
Turns an object T into a CompletableFuture if it's not already- Type Parameters:
T- for two- Parameters:
t- - the object to check- Returns:
- a CompletableFuture
-
toCompletableFutureOrMaterializedObject
Turns a CompletionStage into a CompletableFuture if it's not already, otherwise leaves it alone as a materialized object.- Parameters:
object- - the object to check- Returns:
- a CompletableFuture from a CompletionStage or the materialized object itself
-
tryCatch
-
exceptionallyCompletedFuture
-
orNullCompletedFuture
public static <T> @NonNull CompletableFuture<T> orNullCompletedFuture(@Nullable CompletableFuture<T> completableFuture) If the passed in CompletableFuture is null, then it creates a CompletableFuture that resolves to null- Type Parameters:
T- for two- Parameters:
completableFuture- the CF to use- Returns:
- the completableFuture if it's not null or one that always resoles to null
-