- Type Parameters:
T- the type of item
Multi.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondistinct()Selects all the distinct items from the upstream.distinct(Comparator<? super T> comparator) Selects all the distinct items from the upstream.Selects all the distinct items from the upstream.first()Select the first item from theMulti.first(long n) Selects the firstnitems from theMulti.Selects the first items for the given duration.Selects the first items while the given predicate returnstrue.last()Select the last item from theMulti.last(int n) Selects the lastnitems from theMulti.Selects the items where the given function produced aUniemittingtrue.Selects the items where the given predicate returnstrue.Likewhen(Function), but select at mostlimititems.
-
Constructor Details
-
MultiSelect
-
-
Method Details
-
first
Select the first item from theMulti.If the upstream
Multicontains more than one item, the others are dropped. If the upstream emits a failure before emitting an item, the producedMultiemits the same failure. If the upstream completes without emitting an item first, the producedMultiis empty.- Returns:
- the resulting
Multi
-
last
Select the last item from theMulti.If the upstream
Multicontains more than one item, the others are dropped, only the last one is emitted by the producedMulti. If the upstream emits a failure, the producedMultiemits the same failure. If the upstream completes without emitting an item first, the producedMultiis empty.- Returns:
- the resulting
Multi
-
first
Selects the firstnitems from theMulti.If the upstream
Multicontains more than n items, the others are dropped. If the upstreamMultiemits less than n items, all the items are emitted by the producedMulti. If the upstream emits a failure before emitting n items, the producedMultiemits the same failure after having emitted the first items. If the upstream completes without emitting an item first, the producedMultiis empty. -
last
Selects the lastnitems from theMulti.If the upstream
Multicontains more than n items, the others are dropped. If the upstreamMultiemits less than n items, all the items are emitted by the producedMulti. If the upstream emits a failure, the producedMultiemits the same failure after. No items will be emitted by the producedMulti. If the upstream completes without emitting an item first, the producedMultiis empty. -
first
Selects the first items while the given predicate returnstrue. It calls the predicates for each items, until the predicate returnsfalse. Each item for which the predicates returnedtrueis emitted by the producedMulti. As soon as the predicate returnsfalsefor an item, it stops emitting the item and sends the completion event. The last checked item is not emitted.If the upstream
Multiis empty, the producedMultiis empty. If the upstreamMultiis emitting a failure, while the predicate has not returnedfalseyet, the failure is emitted by the producedMulti. If the predicates throws an exception while testing an item, the producedMultiemits that exception as failure. No more items will be tested or emitted. If the predicates returnstruefor each items from upstream, all the items are selected. Once the predicate returnsfalse, it cancels the subscription to the upstream, and completes the producedMulti.- Parameters:
predicate- the predicate to test the items, must not benull- Returns:
- the resulting
Multi
-
first
Selects the first items for the given duration. It selects each items emitted after the subscription for the given duration.If the upstream
Multiis empty, the producedMultiis empty. If the upstreamMultiis emitting a failure, before the duration expires, the failure is emitted by the producedMulti. If the upstream completes before the given duration, all the items are selected.Once the duration expires, it cancels the subscription to the upstream, and completes the produced
Multi.- Parameters:
duration- the duration, must not benull, must be strictly positive.- Returns:
- the resulting
Multi
-
where
Selects the items where the given predicate returnstrue. It calls the predicates for each items. Each item for which the predicates returnedtrueis emitted by the producedMulti. Others are dropped.If the upstream
Multiis empty, the producedMultiis empty. If the upstreamMultiis emitting a failure, the failure is emitted by the producedMulti. If the predicates throws an exception while testing an item, the producedMultiemits that exception as failure. No more items will be tested or emitted. If the predicates returnstruefor each items from upstream, all the items are selected. The producedMulticompletes when the upstream completes.- Parameters:
predicate- the predicate to test the items, must not benull- Returns:
- the resulting
Multi - See Also:
-
where
Likewhen(Function), but select at mostlimititems. -
when
Selects the items where the given function produced aUniemittingtrue. This method is the asynchronous version ofwhere(Predicate). Instead of a synchronous predicate, it accepts a function producingUni. It calls the function for every item, and depending of the producedUni, it emits the item downstream or drops it. If the returnedUniproducestrue, the item is selected and emitted by the producedMulti, otherwise the item is dropped. The item is only emitted whenUniproduced for that item emitstrue.If the upstream
Multiis empty, the producedMultiis empty. If the upstreamMultiis emitting a failure, the failure is emitted by the producedMulti. If the function throws an exception while testing an item, the producedMultiemits that exception as failure. No more items will be tested or emitted. If the function produced anullUni, the producedMultiemits anNullPointerExceptionas failure. No more items will be tested or emitted. If the function produced a failing Uni, the producedMultiemits that failure. No more items will be tested or emitted. If the function produced aUniemittingnull, the producedMultiemits a failure. No more items will be tested or emitted. If the function accepts all the items from the upstream, all the items are selected. The producedMulticompletes when the upstream completes.This method preserves the item orders.
- Parameters:
predicate- the function to test the items, must not benull, must not producednull- Returns:
- the resulting
Multi
-
distinct
Selects all the distinct items from the upstream. This method usesObject.hashCode()to compare items.Do NOT call this method on unbounded upstream, as it would lead to an
OutOfMemoryError.If the comparison throws an exception, the produced
Multifails. The producedMulticompletes when the upstream sends the completion event.- Returns:
- the resulting
Multi. - See Also:
-
distinct
Selects all the distinct items from the upstream. This method uses the given comparator to compare the items.Do NOT call this method on unbounded upstream, as it would lead to an
OutOfMemoryError.If the comparison throws an exception, the produced
Multifails. The producedMulticompletes when the upstream sends the completion event.Unlike
distinct()which uses aHashSetinternally, this variant uses aTreeSetinitialized with the given comparator. If the comparator isnull, it uses aHashSetas backend.- Parameters:
comparator- the comparator used to compare items. Ifnull, it will use the item'shashCodemethod.- Returns:
- the resulting
Multi. - See Also:
-
distinct
Selects all the distinct items from the upstream. This method uses the given key extractor to extract an object from each item which is then used to compare the items. This method allows for a smaller memory footprint thandistinct()anddistinct(Comparator)as only the extracted keys are held in memory rather than the items themselves.Do NOT call this method on unbounded upstream, as it would lead to an
OutOfMemoryError.If the comparison throws an exception, the produced
Multifails. The producedMulticompletes when the upstream sends the completion event.- Parameters:
keyExtractor- the function used to extract keys from items, must not be null, must not produce null.- Returns:
- the resulting
Multi. - See Also:
-