- java.lang.Object
-
- io.smallrye.mutiny.groups.MultiSkip<T>
-
- Type Parameters:
T- the type of item
public class MultiSkip<T> extends java.lang.ObjectSkips items from the upstreamMulti.- See Also:
MultiSelect
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Multi<T>first()Skips the first item from the upstream and emits all the other items.Multi<T>first(long n)Skips the firstnitems from the upstream and emits all the other items.Multi<T>first(java.time.Duration duration)Skips the the items from the upstream emitted during the the givenduration.Multi<T>first(java.util.function.Predicate<? super T> predicate)Skips the first items passing the givenpredicatefrom the upstream.Multi<T>last()Skips the first items from the upstream.Multi<T>last(int n)Skips the lastnitems from the upstream.Multi<T>repetitions()Skips repetitions from the upstream.Multi<T>repetitions(java.util.Comparator<? super T> comparator)Skips repetitions from the upstream.Multi<T>when(java.util.function.Function<? super T,Uni<java.lang.Boolean>> predicate)Skips the items where the given function produced aUniemittingtrue.Multi<T>where(java.util.function.Predicate<? super T> predicate)Skips the items where the given predicate returnstrue.
-
-
-
Method Detail
-
first
@CheckReturnValue public Multi<T> first(long n)
Skips the firstnitems from the upstream and emits all the other items.If the n is 0, all the items from the upstreams are emitted. If the upstream completes, before emitting n items, the produced
Multiis empty. If the upstream fails, before emitting n items, the producedMultifails with the same failure. If the upstream fails, after having emitted n+ items, the producedMultiwould emit the items followed by the failure.- Parameters:
n- the number of item to skip, must be positive.- Returns:
- the resulting
Multi
-
first
@CheckReturnValue public Multi<T> first()
Skips the first item from the upstream and emits all the other items.If the upstream completes, before emitting an item, the produced
Multiis empty. If the upstream fails, before emitting an item, the producedMultifails with the same failure. If the upstream fails, after having emitted an item, the producedMultiwould emit the items followed by the failure.- Returns:
- the resulting
Multi
-
first
@CheckReturnValue public Multi<T> first(java.util.function.Predicate<? super T> predicate)
Skips the first items passing the givenpredicatefrom the upstream. It calls the predicates for the first items from the upstream until the predicate returnsfalse. Then, that items and all the remaining items are propagated downstream.If the predicate always returns
true, the producedMultiis empty. If the predicate always returnsfalse, the producedMultiemits all the items from the upstream, and the predicates is called only once on the first item. If the upstream completes, and the predicate didn't returnfalseyet, the producedMultiis empty. If the upstream fails, and the predicate didn't returnfalseyet, the producedMultifails with the same failure. If the predicate throws an exception while testing an item, the producedMultiemits the exception as failure.- Parameters:
predicate- the predicate to test the item. Once the predicate returnsfalsefor an item, this item and all the remaining items are propagated downstream.- Returns:
- the resulting
Multi
-
first
@CheckReturnValue public Multi<T> first(java.time.Duration duration)
Skips the the items from the upstream emitted during the the givenduration. The duration is computed from the subscription time.If the upstream completes before the given
duration, the producedMultiis empty. If the upstream fails before the givenduration, the producedMultifails with the same failure. If the upstream didn't emit any items before the delay expired, the producedMultiemits the same events as the upstream.- Parameters:
duration- the duration for which the items from upstream are skipped. Must be strictly positive.- Returns:
- the resulting
Multi
-
last
@CheckReturnValue public Multi<T> last(int n)
Skips the lastnitems from the upstream. All the previous items are emitted by the producedMulti.If the n is 0, all the items from the upstreams are emitted. If the upstream completes, before emitting n items, the produced
Multiis empty. If the upstream fails, before emitting n items, the producedMultifails with the same failure. the producedMultiwould not emit any items. If the upstream fails, after having emitted n items, the producedMultiwould emit the items followed by the failure.- Parameters:
n- the number of item to skip, must be positive.- Returns:
- the resulting
Multi
-
last
@CheckReturnValue public Multi<T> last()
Skips the first items from the upstream. All the previous items are emitted by the producedMulti.If the upstream completes, before emitting an item, the produced
Multiis empty. If the upstream fails, before emitting an item, the producedMultifails with the same failure. the producedMultiwould not emit any items.- Returns:
- the resulting
Multi
-
repetitions
@CheckReturnValue public Multi<T> repetitions()
Skips repetitions from the upstream. So, if the upstream emits consecutively the same item twice, it drops the second occurrence.The items are compared using the
Object.equals(Object)method.If the upstream emits a failure, the produced
Multiemits a failure. If the comparison throws an exception, the producedMultiemits that exception as failure. The producesMulticompletes when the upstream completes.Unlike
MultiSelect.distinct(), this method can be called on unbounded upstream, as it only keeps a reference on the last item.- Returns:
- the resulting
Multi - See Also:
MultiSelect.distinct(),repetitions(Comparator)
-
repetitions
@CheckReturnValue public Multi<T> repetitions(java.util.Comparator<? super T> comparator)
Skips repetitions from the upstream. So, if the upstream emits consecutively the same item twice, it drops the second occurrence.The items are compared using the given comparator.
If the upstream emits a failure, the produced
Multiemits a failure. If the comparison throws an exception, the producedMultiemits that exception as failure. The producesMulticompletes when the upstream completes.Unlike
MultiSelect.distinct(), this method can be called on unbounded upstream, as it only keeps a reference on the last item.- Parameters:
comparator- the comparator, must not benull- Returns:
- the resulting
Multi - See Also:
MultiSelect.distinct(),repetitions()
-
where
@CheckReturnValue public Multi<T> where(java.util.function.Predicate<? super T> predicate)
Skips the items where the given predicate returnstrue. It calls the predicates for each items. Each item for which the predicates returnedfalseis 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 returnsfalsefor each items from upstream, all the items are propagated downstream. If the predicates returnstruefor each items from upstream, the produceMultiis empty. The producedMulticompletes when the upstream completes.This function is the opposite of
MultiSelect.where(Predicate)which selects the passing items.- Parameters:
predicate- the predicate to test the items, must not benull- Returns:
- the resulting
Multi - See Also:
when(Function),MultiSelect.where(Predicate)
-
when
@CheckReturnValue public Multi<T> when(java.util.function.Function<? super T,Uni<java.lang.Boolean>> predicate)
Skips 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 (when the uni producesfalse) or drops it (when the uni producestrue). The item is only emitted whenUniproduced for that item emitsfalse.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. 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
-
-