Class UniOnItemOrFailure<T>


  • public class UniOnItemOrFailure<T>
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Uni<T> call​(java.util.function.BiFunction<? super T,​java.lang.Throwable,​Uni<?>> callback)
      Produces a new Uni invoking the given callback when the item or failure event is fired.
      Uni<T> call​(java.util.function.Supplier<Uni<?>> callback)
      Produces a new Uni invoking the given callback when the item or failure event is fired.
      Uni<T> invoke​(java.lang.Runnable callback)
      Produces a new Uni invoking the given callback when the item or failure event is fired.
      Uni<T> invoke​(java.util.function.BiConsumer<? super T,​java.lang.Throwable> callback)
      Produces a new Uni invoking the given callback when the item or failure event is fired.
      <R> Uni<R> transform​(java.util.function.BiFunction<? super T,​java.lang.Throwable,​? extends R> mapper)
      Produces a new Uni invoking the given function when the current Uni fires the item or failure event.
      <R> Uni<R> transformToUni​(Functions.TriConsumer<? super T,​java.lang.Throwable,​UniEmitter<? super R>> consumer)
      Transforms the received item or failure asynchronously, forwarding the events emitted by the UniEmitter provided to the given consumer.
      <R> Uni<R> transformToUni​(java.util.function.BiFunction<? super T,​java.lang.Throwable,​Uni<? extends R>> mapper)
      Transforms the received item or failure asynchronously, forwarding the events emitted by another Uni produced by the given mapper.
      • Methods inherited from class java.lang.Object

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

      • UniOnItemOrFailure

        public UniOnItemOrFailure​(Uni<T> upstream)
    • Method Detail

      • invoke

        @CheckReturnValue
        public Uni<T> invoke​(java.util.function.BiConsumer<? super T,​java.lang.Throwable> callback)
        Produces a new Uni invoking the given callback when the item or failure event is fired. Note that the item can be null, so detecting failures must be done by checking whether the failure parameter is null.
        Parameters:
        callback - the callback, must not be null
        Returns:
        the new Uni
      • invoke

        @CheckReturnValue
        public Uni<T> invoke​(java.lang.Runnable callback)
        Produces a new Uni invoking the given callback when the item or failure event is fired. The failure or item is being ignore by the callback.
        Parameters:
        callback - the callback, must not be null
        Returns:
        the new Uni
      • call

        @CheckReturnValue
        public Uni<T> call​(java.util.function.BiFunction<? super T,​java.lang.Throwable,​Uni<?>> callback)
        Produces a new Uni invoking the given callback when the item or failure event is fired. Note that the item can be null, so detecting failures must be done by checking whether the failure parameter is null.
        Parameters:
        callback - the callback, must not be null
        Returns:
        the new Uni
      • call

        @CheckReturnValue
        public Uni<T> call​(java.util.function.Supplier<Uni<?>> callback)
        Produces a new Uni invoking the given callback when the item or failure event is fired. The failure or item is being ignore by the callback.
        Parameters:
        callback - the callback, must not be null
        Returns:
        the new Uni
      • transform

        @CheckReturnValue
        public <R> Uni<R> transform​(java.util.function.BiFunction<? super T,​java.lang.Throwable,​? extends R> mapper)
        Produces a new Uni invoking the given function when the current Uni fires the item or failure event. Note that the item can be null, so detecting failures must be done by checking whether the failure parameter is null.

        The function receives the item and failure as parameters, and can transform the item or recover from the failure. The returned object is sent downstream as item.

        For asynchronous composition, see transformToUni(BiFunction).

        Type Parameters:
        R - the type of Uni item
        Parameters:
        mapper - the mapper function, must not be null
        Returns:
        the new Uni
      • transformToUni

        @CheckReturnValue
        public <R> Uni<R> transformToUni​(java.util.function.BiFunction<? super T,​java.lang.Throwable,​Uni<? extends R>> mapper)
        Transforms the received item or failure asynchronously, forwarding the events emitted by another Uni produced by the given mapper.

        Note that the item can be null, so detecting failures must be done by checking whether the failure parameter is null.

        The mapper is called with the item produced by the upstream or the propagated failure. It produces an Uni, possibly using another type of item (R). It can be used to recover from a failure. The events fired by the produced Uni are forwarded to the Uni returned by this method.

        This operation is generally named flatMap.

        Type Parameters:
        R - the type of item
        Parameters:
        mapper - the function called with the item and failure sent by the upstream Uni to produce another Uni, must not be null, must not return null.
        Returns:
        a new Uni that would fire events from the uni produced by the mapper function, possibly in an asynchronous manner.
      • transformToUni

        @CheckReturnValue
        public <R> Uni<R> transformToUni​(Functions.TriConsumer<? super T,​java.lang.Throwable,​UniEmitter<? super R>> consumer)
        Transforms the received item or failure asynchronously, forwarding the events emitted by the UniEmitter provided to the given consumer.

        The consumer is called with the item event or failure event emitted by the current Uni and an emitter used to fire events downstream.

        As the item received from upstream can be null, detecting a failure must be done by checking whether the failure passed to the consumer is null.

        Type Parameters:
        R - the type of item emitted by the emitter
        Parameters:
        consumer - the function called with the item of the this Uni and an UniEmitter. It must not be null.
        Returns:
        a new Uni that would fire events from the emitter consumed by the mapper function, possibly in an asynchronous manner.