- java.lang.Object
-
- io.smallrye.mutiny.groups.UniOnNotNull<T>
-
public class UniOnNotNull<T> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description UniOnNotNull(Uni<T> upstream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Uni<T>
call(java.util.function.Function<? super T,Uni<?>> action)
Produces a newUni
invoking the given @{code action} when theitem
event is received.Uni<T>
call(java.util.function.Supplier<Uni<?>> action)
Produces a newUni
invoking the given @{code action} when theitem
event is received.Uni<T>
failWith(java.lang.Throwable failure)
Uni<T>
failWith(java.util.function.Supplier<? extends java.lang.Throwable> supplier)
Uni<T>
invoke(java.lang.Runnable callback)
Produces a newUni
invoking the given callback when theitem
event is fired.Uni<T>
invoke(java.util.function.Consumer<? super T> callback)
Produces a newUni
invoking the given callback when theitem
event is fired.<R> Uni<R>
transform(java.util.function.Function<? super T,? extends R> mapper)
<R> Multi<R>
transformToMulti(java.util.function.Function<? super T,? extends java.util.concurrent.Flow.Publisher<? extends R>> mapper)
When thisUni
produces its item (notnull
), call the givenmapper
to produce aFlow.Publisher
.<R> Uni<R>
transformToUni(java.util.function.BiConsumer<? super T,UniEmitter<? super R>> consumer)
Transforms the received item asynchronously, forwarding the events emitted anUniEmitter
consumes by the given consumer.<R> Uni<R>
transformToUni(java.util.function.Function<? super T,Uni<? extends R>> mapper)
Transforms the received item asynchronously, forwarding the events emitted by anotherUni
produced by the givenmapper
.
-
-
-
Method Detail
-
invoke
@CheckReturnValue public Uni<T> invoke(java.util.function.Consumer<? super T> callback)
Produces a newUni
invoking the given callback when theitem
event is fired. If the item isnull
, the callback is not invoked.- Parameters:
callback
- the callback, must not benull
- Returns:
- the new
Uni
-
invoke
@CheckReturnValue public Uni<T> invoke(java.lang.Runnable callback)
Produces a newUni
invoking the given callback when theitem
event is fired. If the item isnull
, the callback is not invoked.- Parameters:
callback
- the callback, must not benull
- Returns:
- the new
Uni
-
call
@CheckReturnValue public Uni<T> call(java.util.function.Function<? super T,Uni<?>> action)
Produces a newUni
invoking the given @{code action} when theitem
event is received. Note that if the received item isnull
, the action is not executed, and the item is propagated downstream.Unlike
invoke(Consumer)
, the passed function returns aUni
. When the producedUni
sends its result, the result is discarded, and the original (non null)item
is forwarded downstream. If the producedUni
fails, the failure is propagated downstream.- Parameters:
action
- the callback, must not benull
- Returns:
- the new
Uni
-
call
@CheckReturnValue public Uni<T> call(java.util.function.Supplier<Uni<?>> action)
Produces a newUni
invoking the given @{code action} when theitem
event is received. Note that if the received item isnull
, the action is not executed.Unlike
invoke(Consumer)
, the passed function returns aUni
. When the producedUni
sends its result, the result is discarded, and the original (non null)item
is forwarded downstream. If the producedUni
fails, the failure is propagated downstream.- Parameters:
action
- the callback, must not benull
and must not returnnull
- Returns:
- the new
Uni
-
transform
@CheckReturnValue public <R> Uni<R> transform(java.util.function.Function<? super T,? extends R> mapper)
Produces a newUni
invoking the given function when the currentUni
fires theitem
event. The function receives the (non-null) item as parameter, and can transform it. The returned object is sent downstream asitem
.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 benull
- Returns:
- the new
Uni
-
transformToUni
@CheckReturnValue public <R> Uni<R> transformToUni(java.util.function.Function<? super T,Uni<? extends R>> mapper)
Transforms the received item asynchronously, forwarding the events emitted by anotherUni
produced by the givenmapper
.The mapper is called with the item event of the current
Uni
and produces anUni
, possibly using another type of item (R
). The events fired by producedUni
are forwarded to theUni
returned by this method.If the item is
null
, the mapper is not called, andnull
is propagated downstream.This operation is generally named
flatMap
.
-
transformToMulti
@CheckReturnValue public <R> Multi<R> transformToMulti(java.util.function.Function<? super T,? extends java.util.concurrent.Flow.Publisher<? extends R>> mapper)
When thisUni
produces its item (notnull
), call the givenmapper
to produce aFlow.Publisher
. Continue the pipeline with this publisher (as aMulti
).The mapper is called with the item event of the current
Uni
and produces aFlow.Publisher
, possibly using another type of item (R
). Events fired by the producedFlow.Publisher
are forwarded to theMulti
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 resultingMulti
- Parameters:
mapper
- the mapper, must not benull
, may expect to receivenull
as item.- Returns:
- the multi
-
transformToUni
@CheckReturnValue public <R> Uni<R> transformToUni(java.util.function.BiConsumer<? super T,UniEmitter<? super R>> consumer)
Transforms the received item asynchronously, forwarding the events emitted anUniEmitter
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 producedUni
.If the incoming item is
null
, theconsumer
is not called and anull
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 thisUni
and anUniEmitter
. It must not benull
.- 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(java.util.function.Supplier<? extends java.lang.Throwable> supplier)
If the currentUni
emits an item, the producedUni
emits the retrieved failure using the givenSupplier
.- Parameters:
supplier
- the supplier to produce the failure, must not benull
, must not producenull
- Returns:
- the new
Uni
-
-