| Modifier and Type | Method and Description |
|---|---|
<T> Uni<T> |
completionStage(CompletionStage<? extends T> stage)
|
<T> Uni<T> |
completionStage(Supplier<? extends CompletionStage<? extends T>> supplier)
|
<T,S> Uni<T> |
completionStage(Supplier<S> stateSupplier,
Function<S,? extends CompletionStage<? extends T>> mapper)
|
<I,T> Uni<T> |
converter(UniConverter<I,T> converter,
I instance)
Creates a new
Uni from the passed instance with the passed converter. |
<T> Uni<T> |
deferred(Supplier<? extends Uni<? extends T>> supplier)
|
<T,S> Uni<T> |
deferred(Supplier<S> stateSupplier,
Function<S,? extends Uni<? extends T>> mapper)
|
<T> Uni<T> |
emitter(Consumer<UniEmitter<? super T>> consumer)
Creates a
Uni deferring the logic to the given consumer. |
<T,S> Uni<T> |
emitter(Supplier<S> stateSupplier,
BiConsumer<S,UniEmitter<? super T>> consumer)
Creates a
Uni deferring the logic to the given consumer. |
<T> Uni<T> |
failure(Supplier<Throwable> supplier)
Creates a
Uni that emits a failure event produced using the passed supplier immediately after
being subscribed to. |
<T> Uni<T> |
failure(Throwable failure)
Creates a
Uni that emits a failure event immediately after being subscribed to. |
<T> Uni<T> |
item(Supplier<? extends T> supplier)
Creates a new
Uni that completes immediately after being subscribed to with the specified (potentially
null) value. |
<T,S> Uni<T> |
item(Supplier<S> stateSupplier,
Function<S,? extends T> mapper)
Creates a new
Uni that completes immediately after being subscribed to with the specified (potentially
null) value. |
<T> Uni<T> |
item(T item)
Creates a new
Uni that completes immediately after being subscribed to with the specified (potentially
null) item. |
<T> Uni<T> |
multi(Multi<T> multi)
|
<T> Uni<T> |
nothing()
|
<T> Uni<T> |
nullItem()
Creates a new
Uni that completes with a null item. |
<T> Uni<T> |
optional(Optional<T> optional)
Creates a new
Uni that completes immediately after being subscribed to with the item based on the value
contained in the given optional if Optional.isPresent() or null otherwise. |
<T> Uni<T> |
optional(Supplier<Optional<T>> supplier)
Creates a new
Uni that completes immediately after being subscribed to with the item based on the value
contained in the given optional if Optional.isPresent() or null otherwise. |
<T> Uni<T> |
publisher(org.reactivestreams.Publisher<? extends T> publisher)
Creates a
Uni from the passed Publisher. |
Uni<Void> |
voidItem()
Creates a new
Uni that completes with a null item. |
public static final UniCreate INSTANCE
public <I,T> Uni<T> converter(UniConverter<I,T> converter, I instance)
Uni from the passed instance with the passed converter.public <T> Uni<T> completionStage(CompletionStage<? extends T> stage)
Uni from the given CompletionStage or CompletableFuture.
The produced Uni emits the item of the passed CompletionStage. If the CompletionStage
never completes (or failed), the produced Uni would not emit the item or failure
events.
Cancelling the subscription on the produced Uni cancels the passed CompletionStage
(calling CompletableFuture.cancel(boolean) on the future retrieved using
CompletionStage.toCompletableFuture().
If the stage has already been completed (or failed), the produced Uni sends the item or failure
immediately after subscription. If it's not the case, the subscriber's callbacks are called on the thread used
by the passed CompletionStage.
T - the type of itemstage - the stage, must not be nullUnipublic <T,S> Uni<T> completionStage(Supplier<S> stateSupplier, Function<S,? extends CompletionStage<? extends T>> mapper)
Uni from the given CompletionStage or CompletableFuture.
The produced Uni emits the item of the passed CompletionStage. If the CompletionStage
never completes (or failed), the produced Uni would not emit the item or failure
events.
Cancelling the subscription on the produced Uni cancels the passed CompletionStage
(calling CompletableFuture.cancel(boolean) on the future retrieved using
CompletionStage.toCompletableFuture().
If the stage has already been completed (or failed), the produced Uni sends the item or failure
immediately after subscription. If it's not the case, the subscriber's callbacks are called on the thread used
by the passed CompletionStage.
This variant of completionStage(CompletionStage) allows passing a state supplier. This supplier allows
sharing some state between the subscribers. It is particularly useful when using Uni.repeat()
as you can pass a shared state (for example a page counter, like an AtomicInteger, if you implement pagination).
The state supplier is called once, during the first subscription. Note that the mapper is called for every
subscription.
The state supplier should produce a container wrapping the shared state. This shared state must be thread-safe.
T - the type of itemS - the type of the statestateSupplier - the state supplier, must not return null, must not be nullmapper - the taking the shared state and producing the completion stage.Unipublic <T> Uni<T> completionStage(Supplier<? extends CompletionStage<? extends T>> supplier)
Uni from the given CompletionStage or CompletableFuture. The future is
created by invoking the passed Supplier lazily at subscription time.
The produced Uni emits the item of the passed CompletionStage. If the CompletionStage
never completes (or failed), the produced Uni would not emit an item or a failure.
Cancelling the subscription on the produced Uni cancels the passed CompletionStage
(calling CompletableFuture.cancel(boolean) on the future retrieved using
CompletionStage.toCompletableFuture().
If the produced stage has already been completed (or failed), the produced Uni sends the item or failure
immediately after subscription. If it's not the case the subscriber's callbacks are called on the thread used
by the passed CompletionStage.
If the supplier throws an exception, a failure event with the exception is fired. If the supplier produces
null, a failure event containing a NullPointerException is fired.
T - the type of itemsupplier - the supplier, must not be null, must not produce nullUnipublic <T> Uni<T> publisher(org.reactivestreams.Publisher<? extends T> publisher)
Uni from the passed Publisher.
The produced Uni emits the first item/value emitted by the passed Publisher.
If the publisher emits multiple values, others are dropped. If the publisher emits a failure after a value, the
failure is dropped. If the publisher emits the completion signal before having emitted a value, the produced
Uni emits a null item event.
When a subscriber subscribes to the produced Uni, it subscribes to the Publisher and requests
1 item. When the first item is received, the subscription is cancelled. Note that each Uni's subscriber
would produce a new subscription.
If the Uni's observer cancels its subscription, the subscription to the Publisher is also cancelled.
T - the type of itempublisher - the publisher, must not be nullUnipublic <T> Uni<T> item(Supplier<? extends T> supplier)
Uni that completes immediately after being subscribed to with the specified (potentially
null) value. The item is retrieved lazily at subscription time, using the passed
Supplier. Unlike deferred(Supplier), the supplier produces an item and not an Uni.
If the supplier produces null, null is used as item event.
If the supplier throws an exception, a failure event with the exception is fired. If the supplier produces
null, a failure event containing a NullPointerException is fired.
T - the type of itemsupplier - the item supplier, must not be null, can produce nullUnipublic <T,S> Uni<T> item(Supplier<S> stateSupplier, Function<S,? extends T> mapper)
Uni that completes immediately after being subscribed to with the specified (potentially
null) value. The item is retrieved lazily at subscription time, using the passed
Supplier. Unlike deferred(Supplier), the supplier produces an item and not an Uni.
This variant of item(Supplier) allows passing a state supplier. This supplier allows
sharing some state between the subscribers. It is particularly useful when using Uni.repeat()
as you can pass a shared state (for example a page counter, like an AtomicInteger, if you implement pagination).
The state supplier is called once, during the first subscription. Note that the mapper is called for every
subscription.
The state supplier should produce a container wrapping the shared state. This shared state must be thread-safe.
T - the type of itemS - the type of the statestateSupplier - the state supplier, must not return null, must not be nullmapper - the taking the shared state and producing the item.Unipublic <T> Uni<T> item(T item)
Uni that completes immediately after being subscribed to with the specified (potentially
null) item.T - the type of itemitem - the item, can be nullUnipublic Uni<Void> voidItem()
Uni that completes with a null item.Uni with a null itempublic <T> Uni<T> nullItem()
Uni that completes with a null item.T - the type of itemUni with a null itempublic <T> Uni<T> optional(Optional<T> optional)
Uni that completes immediately after being subscribed to with the item based on the value
contained in the given optional if Optional.isPresent() or null otherwise.T - the type of the produced itemoptional - the optional, must not be nullUnipublic <T> Uni<T> optional(Supplier<Optional<T>> supplier)
Uni that completes immediately after being subscribed to with the item based on the value
contained in the given optional if Optional.isPresent() or null otherwise. Unlike
optional(Optional), the passed Supplier is called lazily at subscription time.
If the supplier throws an exception, a failure event with the exception is fired. If the supplier produces
null, a failure event containing a NullPointerException is fired.
T - the type of the produced itemsupplier - the supplier, must not be null, must not return nullUnipublic <T> Uni<T> emitter(Consumer<UniEmitter<? super T>> consumer)
Uni deferring the logic to the given consumer. The consumer can be used with callback-based
APIs to fire at most one item (potentially null), or a failure event.
Using this method, you can produce a Uni based on listener or callbacks APIs. You register the listener
in the consumer and emits the item / failure events when the listener is invoked. Don't forget to unregister
the listener on cancellation.
Note that the emitter only forwards the first event, subsequent events are dropped.
If the consumer throws an exception, a failure event with the exception is fired if the first event was already fired.
T - the type of itemconsumer - callback receiving the UniEmitter and events downstream. The callback is
called for each subscriber (at subscription time). Must not be nullUnipublic <T,S> Uni<T> emitter(Supplier<S> stateSupplier, BiConsumer<S,UniEmitter<? super T>> consumer)
Uni deferring the logic to the given consumer. The consumer can be used with callback-based
APIs to fire at most one item (potentially null), or a failure event.
Using this method, you can produce a Uni based on listener or callbacks APIs. You register the listener
in the consumer and emits the item / failure events when the listener is invoked. Don't forget to unregister
the listener on cancellation.
Note that the emitter only forwards the first event, subsequent events are dropped.
If the consumer throws an exception, a failure event with the exception is fired if the first event was already
fired.
This variant of emitter(Consumer) allows passing a state supplier. This supplier allows
sharing some state between the subscribers. It is particularly useful when using Uni.repeat()
as you can pass a shared state (for example a page counter, like an AtomicInteger, if you implement pagination).
The state supplier is called once, during the first subscription. Note that the mapper is called for every
subscription.
The state supplier should produce a container wrapping the shared state. This shared state must be thread-safe.
T - the type of itemS - the type of the statestateSupplier - the state supplier, must not return null, must not be nullconsumer - callback receiving the UniEmitter and events downstream. The callback is
called for each subscriber (at subscription time). Must not be nullUnipublic <T> Uni<T> deferred(Supplier<? extends Uni<? extends T>> supplier)
Uni that supplies an Uni to subscribe to for each
UniSubscriber. The supplier is called at subscription time.
In practice, it defers the Uni creation at subscription time and allows each subscriber to get different
Uni. So, it does not create the Uni until an subscriber subscribes, and
creates a fresh Uni for each subscriber.
Unlike item(Supplier), the supplier produces an Uni (and not an item).
If the supplier throws an exception, a failure event with the exception is fired. If the supplier produces
null, a failure event containing a NullPointerException is fired.
T - the type of itemsupplier - the supplier, must not be null, must not produce nullUnipublic <T,S> Uni<T> deferred(Supplier<S> stateSupplier, Function<S,? extends Uni<? extends T>> mapper)
Uni that supplies an Uni to subscribe to for each
UniSubscriber. The supplier is called at subscription time.
In practice, it defers the Uni creation at subscription time and allows each subscriber to get different
Uni. So, it does not create the Uni until an subscriber subscribes, and
creates a fresh Uni for each subscriber.
Unlike item(Supplier), the supplier produces an Uni (and not an item).
If the supplier throws an exception, a failure event with the exception is fired. If the supplier produces
null, a failure event containing a NullPointerException is fired.
This variant of deferred(Supplier) allows passing a state supplier. This supplier allows
sharing some state between the subscribers. It is particularly useful when using Uni.repeat()
as you can pass a shared state (for example a page counter, like an AtomicInteger, if you implement pagination).
The state supplier is called once, during the first subscription. Note that the mapper is called for every
subscription.
The state supplier should produce a container wrapping the shared state. This shared state must be thread-safe.
T - the type of itemS - the type of the statestateSupplier - the state supplier, must not return null, must not be nullmapper - the taking the shared state and producing the completion stage.Unipublic <T> Uni<T> failure(Throwable failure)
Uni that emits a failure event immediately after being subscribed to.public <T> Uni<T> failure(Supplier<Throwable> supplier)
Uni that emits a failure event produced using the passed supplier immediately after
being subscribed to. The supplier is called at subscription time, and produces an instance of Throwable.
If the supplier throws an exception, a failure event is fired with this exception.
If the supplier produces null, a failure event is fired with a NullPointerException.public <T> Uni<T> nothing()
T - the virtual type of itemUnipublic <T> Uni<T> multi(Multi<T> multi)
Uni from the given Multi.
When a subscriber subscribes to the returned Uni, it subscribes to the Multi and requests one
item. The event emitted by the Multi are then forwarded to the Uni:
UniUninull item is fired by the produces Uni
If the subscription on the produced Uni is cancelled, the subscription to the passed Multi is
also cancelled.
T - the type of itemmulti - the multi, must not be nullUniCopyright © 2019–2020 SmallRye. All rights reserved.