- Type Parameters:
T- the type of item sent by the upstream.
Uni.
IMPORTANT: Do not use on unbounded streams, as it would lead to OutOfMemoryError.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasList()asMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction) <K> Uni<Map<K, Collection<T>>> asMultiMap(Function<? super T, ? extends K> keyMapper) <K,V> Uni <Map<K, Collection<V>>> asMultiMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) asSet()first()<X> Uni<X> in(Supplier<X> supplier, BiConsumer<X, T> accumulator) last()Collects only the items from the upstream that passes the given predicate.Collects only the items from the upstream that passes the given predicate.<X,A> Uni <X>
-
Constructor Details
-
MultiCollect
-
-
Method Details
-
first
Creates aUnireceiving the first item emitted by the upstreamMulti. If theMultiis empty, the producedUnifiresnullas item when theMultiemits the completion event. If theMultiemits a failure before having emitted an item, the producedUnipropagates the failure.- Returns:
- the produced uni
-
last
Creates aUnireceiving the last item emitted by the upstreamMulti. The last item is item fired just before the completion event.If the
Multiis empty, the producedUnifiresnullas item when theMultiemits the completion event. If theMultiemits a failure, the producedUnipropagates the failure.- Returns:
- the produced uni
-
asList
-
asSet
-
with
-
in
Produces a newUniemitting a container with all items emitted by thisMulti.It produces the container instance using the passed
Supplier(at subscription time) and then call theaccumulatorbi-consumer for each item emitted by theMulti.The collected item will be emitted when this
Multifires the completion event.If the
Multipropagates a failure, the producesUnipropagates the same failure, even if some items have been collected. If theMultiis empty, the supplied container is returned empty- Type Parameters:
X- the type of the container produced by the supplier.- Parameters:
supplier- the supplier of the container instance, called at Subscription time. Must not benull. Must not producenullaccumulator- a consumer called on every item with the container instance and the item. It should add the item into the container. Must not benull- Returns:
- a
Uniemitting the collected container as item when thisMulticompletes
-
asMap
Produces anUniemitting aMapofkey -> itemfor each item emitted by thisMulti. The collected map is emitted by the producedUniwhen theMultifires the completion event.The key is extracted from each item by applying the
keyMapperfunction. In case of conflict, the associated value will be the most recently emitted item.- Type Parameters:
K- the type of the key extracted from each item emitted by thisMulti- Parameters:
keyMapper- aFunctionto map item to a key for theMap. Must not benull, must not producenull- Returns:
- a
Uniemitting an item with the collectedMap. The uni emits the item when thisMulticompletes
-
asMap
@CheckReturnValue public <K,V> Uni<Map<K,V>> asMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) Produces anUniemitting aMapofkey -> mapped itemfor each item emitted by thisMulti. The collected map is emitted by the producedUniwhen theMultifires the completion event.The key is extracted from each item by applying the
keyMapperfunction. In case of conflict, the associated value will be the most recently emitted item. The value is computed by applying thevalueMapperfunction.- Type Parameters:
K- the type of the key extracted from each item emitted by thisMultiV- the type of the value extracted from each item emitted by thisMulti- Parameters:
keyMapper- aFunctionto map item to a key for theMap. Must not benull, must not producenullvalueMapper- aFunctionto map item to a value for theMap. Must not benull, must not producenull- Returns:
- a
Uniemitting an item with the collectedMap. The uni emits the item when thisMulticompletes
-
asMap
@CheckReturnValue public <K,V> Uni<Map<K,V>> asMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction) Produces anUniemitting aMapofkey -> mapped itemfor each item emitted by thisMulti. The collected map is emitted by the producedUniwhen theMultifires the completion event.The key is extracted from each item by applying the
keyMapperfunction. In case of conflictmergeFunctionis used to choose which item should be emitted. The value is computed by applying thevalueMapperfunction.- Type Parameters:
K- the type of the key extracted from each item emitted by thisMultiV- the type of the value extracted from each item emitted by thisMulti- Parameters:
keyMapper- aFunctionto map item to a key for theMap. Must not benull, must not producenullvalueMapper- aFunctionto map item to a value for theMap. Must not benull, must not producenullmergeFunction- aBinaryOperatorused to resolve collisions between values associated with the same key. Must not benull. In case it returns null the owner key will be removed from theMap- Returns:
- a
Uniemitting an item with the collectedMap. The uni emits the item when thisMulticompletes
-
asMultiMap
@CheckReturnValue public <K,V> Uni<Map<K,Collection<V>>> asMultiMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) Produces anUniemitting aMapofkey -> Collection of mapped valuesfor each item emitted by thisMulti. The collected map is emitted by the producedUniwhen theMultifires the completion event.The key is extracted from each item by applying the
keyMapperfunction. The value is a collection containing all the values mapped to the specific key. The value is computed by applying thevalueMapperfunction.- Type Parameters:
K- the type of the key extracted from each item emitted by thisMultiV- the type of the value extracted from each item emitted by thisMulti- Parameters:
keyMapper- aFunctionto map item to a key for theMap. Must not benull, must not producenullvalueMapper- aFunctionto map item to a value for theMap. Must not benull, must not producenull- Returns:
- a
Uniemitting an item with the collectedMap. The uni emits the item when thisMulticompletes
-
asMultiMap
@CheckReturnValue public <K> Uni<Map<K,Collection<T>>> asMultiMap(Function<? super T, ? extends K> keyMapper) Produces anUniemitting aMapofkey -> Collection of itemsfor each item emitted by thisMulti. The collected map is emitted by the producedUniwhen theMultifires the completion event.The key is extracted from each item by applying the
keyMapperfunction. The value is a collection containing all the items emitted associated to the specific key.- Type Parameters:
K- the type of the key extracted from each item emitted by thisMulti- Parameters:
keyMapper- aFunctionto map item to a key for theMap.Must not benull, must not producenull- Returns:
- a
Uniemitting an item with the collectedMap. The uni emits the item when thisMulticompletes
-
where
Collects only the items from the upstream that passes the given predicate. This method is equivalent toupstream.select().when(predicate).collect().For each item, it calls the predicate. If the predicate returns
true, it collects the item, otherwise it discards the item. If the predicate throws an exception, it propagates that exception as failure.- Parameters:
predicate- the predicate, must not benull.- Returns:
- the object to configure the item collection.
-
when
Collects only the items from the upstream that passes the given predicate. Unlikewhere(Predicate), the predicate returns aUni<Boolean>, which support asynchronous tests.This method is equivalent to
upstream.select().where(predicate).collect().For each item, it calls the predicate. If the predicate emits the item
true, it collects the item, otherwise it discards the item. If the predicate throws an exception or emits a failure, it propagates that exception as failure.- Parameters:
predicate- the predicate, must not benull.- Returns:
- the object to configure the item collection.
-