Class UniAwait<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.UniAwait<T>
-
- Type Parameters:
T- the type of item
public class UniAwait<T> extends java.lang.ObjectWaits and returns the item emitted by theUni. If theUnireceives a failure, the failure is thrown.This class lets you configure how to retrieves the item of a
Uniby blocking the caller thread.- See Also:
Uni.await()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UniAwaitOptional<T>asOptional()Indicates that you are awaiting for the item event of the attachedUniwrapped into anOptional.TatMost(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.Tindefinitely()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 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, potentiallynullif the operation returnsnull. 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.
- Returns:
- the item from the
Uni, potentiallynull
-
atMost
public 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, potentiallynullif the operation returnsnull. 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
-
asOptional
@CheckReturnValue public UniAwaitOptional<T> asOptional()
Indicates that you are awaiting for the item event of the attachedUniwrapped into anOptional. So if theUnifiresnullas item, you receive an emptyOptional.- Returns:
- the
UniAwaitOptionalconfigured to produce anOptional.
-
-