Package io.smallrye.mutiny.groups
Class UniAwaitOptional<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.UniAwaitOptional<T>
-
- Type Parameters:
T- the type of the item
public class UniAwaitOptional<T> extends java.lang.ObjectLikesUniAwaitbut wrapping the item event into anOptional. This optional is empty if theUnifiresnull.- See Also:
Uni.await()
-
-
Constructor Summary
Constructors Constructor Description UniAwaitOptional(Uni<T> upstream, Context context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<T>atMost(java.time.Duration duration)Subscribes to theUniand waits (blocking the caller thread) at most the given duration until an item or failure is fired by the upstream uni.java.util.Optional<T>indefinitely()Subscribes to theUniand waits (blocking the caller thread) indefinitely until aitemevent is fired or afailureevent is fired by the upstream uni.
-
-
-
Method Detail
-
indefinitely
public java.util.Optional<T> indefinitely()
Subscribes to theUniand waits (blocking the caller thread) indefinitely until aitemevent is fired or afailureevent is fired by the upstream uni.If the
Unifires an item, it returns that item wrapped into anOptional. If the item isnullthe returned optional is empty. If theUnifires a failure, the original exception is thrown (wrapped in aCompletionExceptionit's a checked exception).Note that each call to this method triggers a new subscription.
-
atMost
public java.util.Optional<T> atMost(java.time.Duration duration)
Subscribes to theUniand waits (blocking the caller thread) at most the given duration until an item or failure is fired by the upstream uni.If the
Unifires an item, it returns that item wrapped into anOptional. If the item isnullthe returned optional is empty. If theUnifires a failure, the original exception is thrown (wrapped in aCompletionExceptionit's a checked exception). If the timeout is reached before completion, aTimeoutExceptionis thrown.Note that each call to this method triggers a new subscription.
- Parameters:
duration- the duration, must not benull, must not be negative or zero.- Returns:
- the item from the
Uni, potentiallynull
-
-