Class MultiSkip<T>

  • Type Parameters:
    T - the type of item

    public class MultiSkip<T>
    extends java.lang.Object
    Skips items from the upstream Multi.
    See Also:
    MultiSelect
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiSkip​(Multi<T> upstream)  
    • 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 first n 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 given duration.
      Multi<T> first​(java.util.function.Predicate<? super T> predicate)
      Skips the first items passing the given predicate from the upstream.
      Multi<T> last()
      Skips the first items from the upstream.
      Multi<T> last​(int n)
      Skips the last n 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 a Uni emitting true.
      Multi<T> where​(java.util.function.Predicate<? super T> predicate)
      Skips the items where the given predicate returns true.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiSkip

        public MultiSkip​(Multi<T> upstream)
    • Method Detail

      • first

        @CheckReturnValue
        public Multi<T> first​(long n)
        Skips the first n 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 produced Multi fails with the same failure. If the upstream fails, after having emitted n+ items, the produced Multi would 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 Multi is empty. If the upstream fails, before emitting an item, the produced Multi fails with the same failure. If the upstream fails, after having emitted an item, the produced Multi would 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 given predicate from the upstream. It calls the predicates for the first items from the upstream until the predicate returns false. Then, that items and all the remaining items are propagated downstream.

        If the predicate always returns true, the produced Multi is empty. If the predicate always returns false, the produced Multi 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 return false yet, the produced Multi is empty. If the upstream fails, and the predicate didn't return false yet, the produced Multi fails with the same failure. If the predicate throws an exception while testing an item, the produced Multi emits the exception as failure.

        Parameters:
        predicate - the predicate to test the item. Once the predicate returns false for 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 given duration. The duration is computed from the subscription time.

        If the upstream completes before the given duration, the produced Multi is empty. If the upstream fails before the given duration, the produced Multi fails with the same failure. If the upstream didn't emit any items before the delay expired, the produced Multi 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

        @CheckReturnValue
        public Multi<T> last​(int n)
        Skips the last n items from the upstream. All the previous items are emitted by the produced Multi.

        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 produced Multi fails with the same failure. the produced Multi would not emit any items. If the upstream fails, after having emitted n items, the produced Multi would 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 produced Multi.

        If the upstream completes, before emitting an item, the produced Multi is empty. If the upstream fails, before emitting an item, the produced Multi fails with the same failure. the produced Multi would 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 Multi emits a failure. If the comparison throws an exception, the produced Multi emits that exception as failure. The produces Multi 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

        @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 Multi emits a failure. If the comparison throws an exception, the produced Multi emits that exception as failure. The produces Multi 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 be null
        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 returns true. It calls the predicates for each items. Each item for which the predicates returned false is emitted by the produced Multi. Others are dropped.

        If the upstream Multi is empty, the produced Multi is empty. If the upstream Multi is emitting a failure, the failure is emitted by the produced Multi. If the predicates throws an exception while testing an item, the produced Multi emits that exception as failure. No more items will be tested or emitted. If the predicates returns false for each items from upstream, all the items are propagated downstream. If the predicates returns true for each items from upstream, the produce Multi is empty. The produced Multi completes 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 be null
        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 a Uni emitting true. This method is the asynchronous version of where(Predicate). Instead of a synchronous predicate, it accepts a function producing Uni. It calls the function for every item, and depending of the produced Uni, it emits the item downstream (when the uni produces false) or drops it (when the uni produces true). The item is only emitted when Uni produced for that item emits false.

        If the upstream Multi is empty, the produced Multi is empty. If the upstream Multi is emitting a failure, the failure is emitted by the produced Multi. If the function throws an exception while testing an item, the produced Multi emits that exception as failure. No more items will be tested or emitted. If the function produced a null Uni, the produced Multi emits an NullPointerException as failure. No more items will be tested or emitted. If the function produced a failing Uni, the produced Multi emits that failure. No more items will be tested or emitted. If the function produced a Uni emitting null, the produced Multi emits a failure. No more items will be tested or emitted. The produced Multi completes when the upstream completes.

        This method preserves the item orders.

        Parameters:
        predicate - the function to test the items, must not be null, must not produced null
        Returns:
        the resulting Multi