- All Known Subinterfaces:
AsyncGenerator<E>
- All Known Implementing Classes:
AsyncGenerator.WithEmbed,AsyncGenerator.WithResult,AsyncGeneratorQueue.Generator,GeneratorSubscriber
public interface AsyncGeneratorOperators<E>
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R extends List<E>>
CompletableFuture<R>collectAsync(R result, BiConsumer<R, E> consumer) Collects elements from the AsyncGenerator asynchronously into a list.default Executorexecutor()default AsyncGenerator<E>Filters the elements of this generator based on the given predicate.default <U> AsyncGenerator<U>flatMap(Function<E, CompletableFuture<U>> mapFunction) Maps the elements of this generator to a new asynchronous generator, and flattens the resulting nested generators.default CompletableFuture<Object>forEachAsync(Consumer<E> consumer) Asynchronously iterates over the elements of the AsyncGenerator and applies the given consumer to each element.default <U> AsyncGenerator<U>Maps the elements of this generator to a new asynchronous generator.next()
-
Method Details
-
next
AsyncGenerator.Data<E> next() -
executor
-
map
Maps the elements of this generator to a new asynchronous generator.- Type Parameters:
U- the type of elements in the new generator- Parameters:
mapFunction- the function to map elements to a new asynchronous counterpart- Returns:
- a generator with mapped elements
-
flatMap
Maps the elements of this generator to a new asynchronous generator, and flattens the resulting nested generators.- Type Parameters:
U- the type of elements in the new generator- Parameters:
mapFunction- the function to map elements to a new asynchronous counterpart- Returns:
- a generator with mapped and flattened elements
-
filter
Filters the elements of this generator based on the given predicate. Only elements that satisfy the predicate will be included in the resulting generator.- Parameters:
predicate- the predicate to test elements against- Returns:
- a generator with elements that satisfy the predicate
-
forEachAsync
Asynchronously iterates over the elements of the AsyncGenerator and applies the given consumer to each element.- Parameters:
consumer- the consumer function to be applied to each element- Returns:
- a CompletableFuture representing the completion of the iteration process.
-
collectAsync
Collects elements from the AsyncGenerator asynchronously into a list.- Type Parameters:
R- the type of the result list- Parameters:
result- the result list to collect elements intoconsumer- the consumer function for processing elements- Returns:
- a CompletableFuture representing the completion of the collection process
-