Class UniOnNotNull<T>

java.lang.Object
io.smallrye.mutiny.groups.UniOnNotNull<T>

public class UniOnNotNull<T> extends Object
  • Constructor Details

    • UniOnNotNull

      public UniOnNotNull(Uni<T> upstream)
  • Method Details

    • invoke

      @CheckReturnValue public Uni<T> invoke(Consumer<? super T> callback)
      Produces a new Uni invoking the given callback when the item event is fired. If the item is null, the callback is not invoked.
      Parameters:
      callback - the callback, must not be null
      Returns:
      the new Uni
    • invoke

      @CheckReturnValue public Uni<T> invoke(Runnable callback)
      Produces a new Uni invoking the given callback when the item event is fired. If the item is null, the callback is not invoked.
      Parameters:
      callback - the callback, must not be null
      Returns:
      the new Uni
    • call

      @CheckReturnValue public Uni<T> call(Function<? super T,Uni<?>> action)
      Produces a new Uni invoking the given @{code action} when the item event is received. Note that if the received item is null, the action is not executed, and the item is propagated downstream.

      Unlike invoke(Consumer), the passed function returns a Uni. When the produced Uni sends its result, the result is discarded, and the original (non null) item is forwarded downstream. If the produced Uni fails, the failure is propagated downstream.

      Parameters:
      action - the callback, must not be null
      Returns:
      the new Uni
    • call

      @CheckReturnValue public Uni<T> call(Supplier<Uni<?>> action)
      Produces a new Uni invoking the given @{code action} when the item event is received. Note that if the received item is null, the action is not executed.

      Unlike invoke(Consumer), the passed function returns a Uni. When the produced Uni sends its result, the result is discarded, and the original (non null) item is forwarded downstream. If the produced Uni fails, the failure is propagated downstream.

      Parameters:
      action - the callback, must not be null and must not return null
      Returns:
      the new Uni
    • transform

      @CheckReturnValue public <R> Uni<R> transform(Function<? super T,? extends R> mapper)
      Produces a new Uni invoking the given function when the current Uni fires the item event. The function receives the (non-null) item as parameter, and can transform it. The returned object is sent downstream as item.

      If the item is `null`, the mapper is not called and it produces a null item.

      For asynchronous composition, see transformToUni(Function).

      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(Function<? super T,Uni<? extends R>> mapper)
      Transforms the received item asynchronously, forwarding the events emitted by another Uni produced by the given mapper.

      The mapper is called with the item event of the current Uni and produces an Uni, possibly using another type of item (R). The events fired by produced Uni are forwarded to the Uni returned by this method.

      If the item is null, the mapper is not called, and null is propagated downstream.

      This operation is generally named flatMap.

      Type Parameters:
      R - the type of item
      Parameters:
      mapper - the function called with the item of this Uni and producing the 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.
    • transformToMulti

      @CheckReturnValue public <R> Multi<R> transformToMulti(Function<? super T,? extends Flow.Publisher<? extends R>> mapper)
      When this Uni produces its item (not null), call the given mapper to produce a Flow.Publisher. Continue the pipeline with this publisher (as a Multi).

      The mapper is called with the item event of the current Uni and produces a Flow.Publisher, possibly using another type of item (R). Events fired by the produced Flow.Publisher are forwarded to the Multi returned by this method.

      If the item is `null`, the mapper is not called and an empty Multi is produced.

      This operation is generally named flatMapPublisher.

      Type Parameters:
      R - the type of item produced by the resulting Multi
      Parameters:
      mapper - the mapper, must not be null, may expect to receive null as item.
      Returns:
      the multi
    • transformToUni

      @CheckReturnValue public <R> Uni<R> transformToUni(BiConsumer<? super T,UniEmitter<? super R>> consumer)
      Transforms the received item asynchronously, forwarding the events emitted an UniEmitter consumes by the given consumer.

      The consumer is called with the item event of the current Uni and an emitter uses to fire events. These events are these propagated by the produced Uni.

      If the incoming item is null, the consumer is not called and a null item is propagated downstream.

      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.
    • failWith

      @CheckReturnValue public Uni<T> failWith(Supplier<? extends Throwable> supplier)
      If the current Uni emits an item, the produced Uni emits the retrieved failure using the given Supplier.
      Parameters:
      supplier - the supplier to produce the failure, must not be null, must not produce null
      Returns:
      the new Uni
    • failWith

      @CheckReturnValue public Uni<T> failWith(Throwable failure)
      If the current Uni emits an item, the produced Uni emits the given failure.
      Parameters:
      failure - the exception to fire if the current Uni emits an item. Must not be null.
      Returns:
      the new Uni