Class MultiSkip<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.MultiSkip<T>
-
- Type Parameters:
T
- the type of item
public class MultiSkip<T> extends java.lang.Object
Skips 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 firstn
items 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 givenpredicate
from the upstream.Multi<T>
last()
Skips the first items from the upstream.Multi<T>
last(int n)
Skips the lastn
items 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 aUni
emittingtrue
.Multi<T>
where(java.util.function.Predicate<? super T> predicate)
Skips the items where the given predicate returnstrue
.
-
-
-
Method Detail
-
first
public Multi<T> first(long n)
Skips the firstn
items 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
Multi
is empty. If the upstream fails, before emitting n items, the producedMulti
fails with the same failure. If the upstream fails, after having emitted n+ items, the producedMulti
would emit the items followed by the failure.- Parameters:
n
- the number of item to skip, must be positive.- Returns:
- the resulting
Multi
-
first
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
Multi
is empty. If the upstream fails, before emitting an item, the producedMulti
fails with the same failure. If the upstream fails, after having emitted an item, the producedMulti
would emit the items followed by the failure.- Returns:
- the resulting
Multi
-
first
public Multi<T> first(java.util.function.Predicate<? super T> predicate)
Skips the first items passing the givenpredicate
from 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 producedMulti
is empty. If the predicate always returnsfalse
, the producedMulti
emits 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 returnfalse
yet, the producedMulti
is empty. If the upstream fails, and the predicate didn't returnfalse
yet, the producedMulti
fails with the same failure. If the predicate throws an exception while testing an item, the producedMulti
emits the exception as failure.- Parameters:
predicate
- the predicate to test the item. Once the predicate returnsfalse
for an item, this item and all the remaining items are propagated downstream.- Returns:
- the resulting
Multi
-
first
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 producedMulti
is empty. If the upstream fails before the givenduration
, the producedMulti
fails with the same failure. If the upstream didn't emit any items before the delay expired, the producedMulti
emits 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
public Multi<T> last(int n)
Skips the lastn
items 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
Multi
is empty. If the upstream fails, before emitting n items, the producedMulti
fails with the same failure. the producedMulti
would not emit any items. If the upstream fails, after having emitted n items, the producedMulti
would emit the items followed by the failure.- Parameters:
n
- the number of item to skip, must be positive.- Returns:
- the resulting
Multi
-
last
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
Multi
is empty. If the upstream fails, before emitting an item, the producedMulti
fails with the same failure. the producedMulti
would not emit any items.- Returns:
- the resulting
Multi
-
repetitions
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
Multi
emits a failure. If the comparison throws an exception, the producedMulti
emits that exception as failure. The producesMulti
completes 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
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
Multi
emits a failure. If the comparison throws an exception, the producedMulti
emits that exception as failure. The producesMulti
completes 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
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 returnedfalse
is emitted by the producedMulti
. Others are dropped.If the upstream
Multi
is empty, the producedMulti
is empty. If the upstreamMulti
is emitting a failure, the failure is emitted by the producedMulti
. If the predicates throws an exception while testing an item, the producedMulti
emits that exception as failure. No more items will be tested or emitted. If the predicates returnsfalse
for each items from upstream, all the items are propagated downstream. If the predicates returnstrue
for each items from upstream, the produceMulti
is empty. The producedMulti
completes when the upstream completes. This function is the opposite ofMultiSelect.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
public Multi<T> when(java.util.function.Function<? super T,Uni<java.lang.Boolean>> predicate)
Skips the items where the given function produced aUni
emittingtrue
. 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 whenUni
produced for that item emitsfalse
.If the upstream
Multi
is empty, the producedMulti
is empty. If the upstreamMulti
is emitting a failure, the failure is emitted by the producedMulti
. If the function throws an exception while testing an item, the producedMulti
emits that exception as failure. No more items will be tested or emitted. If the function produced anull
Uni, the producedMulti
emits anNullPointerException
as failure. No more items will be tested or emitted. If the function produced a failing Uni, the producedMulti
emits that failure. No more items will be tested or emitted. If the function produced aUni
emittingnull
, the producedMulti
emits a failure. No more items will be tested or emitted. The producedMulti
completes 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
-
-