Package org.springframework.pulsar.core
Class Resolved<T>
java.lang.Object
org.springframework.pulsar.core.Resolved<T>
- Type Parameters:
T- the resolved type
A resolved value or an exception if it could not be resolved.
- Author:
- Christophe Bornet, Chris Bono, Jonas Geiregat
-
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the exception that may have occurred during resolution.static <T> Resolved<T>failed(RuntimeException reason) Factory method to create aResolvedwhen resolution fails.static <T> Resolved<T>Factory method to create aResolvedwhen resolution fails.inthashCode()voidifResolved(Consumer<? super T> action) Performs the given action with the resolved value if a value was resolved and no exception occurred.voidifResolvedOrElse(Consumer<? super T> action, Consumer<RuntimeException> errorAction) Performs the given action with the resolved value if a non-nullvalue was resolved and no exception occurred.static <T> Resolved<T>of(@Nullable T value) Factory method to create aResolvedwhen resolution succeeds.@Nullable TReturns the resolved value if a value was resolved and no exception occurred, otherwise throws the resolution exception back to the caller.@Nullable TorElseThrow(Supplier<String> wrappingErrorMessage) Returns the resolved value if a value was resolved and no exception occurred, otherwise wraps the resolution exception with the provided error message and throws back to the caller.toString()value()Gets the resolved value.
-
Method Details
-
of
Factory method to create aResolvedwhen resolution succeeds.- Type Parameters:
T- the type of the value- Parameters:
value- the non-nullresolved value- Returns:
- a
Resolvedcontaining the resolved value
-
failed
Factory method to create aResolvedwhen resolution fails.- Type Parameters:
T- the type of the value- Parameters:
reason- the non-nullreason the resolution failed- Returns:
- a
Resolvedcontaining anIllegalArgumentExceptionwith the reason for the failure
-
failed
Factory method to create aResolvedwhen resolution fails.- Type Parameters:
T- the type of the value- Parameters:
reason- the non-nullreason the resolution failed- Returns:
- a
Resolvedcontaining the reason for the failure
-
value
Gets the resolved value.- Returns:
- an optional with the resolved value or empty if failed to resolve
-
exception
Gets the exception that may have occurred during resolution.- Returns:
- an optional with the resolution exception or empty if no error occurred
-
ifResolved
Performs the given action with the resolved value if a value was resolved and no exception occurred.- Parameters:
action- the action to be performed
-
ifResolvedOrElse
Performs the given action with the resolved value if a non-nullvalue was resolved and no exception occurred. Otherwise, if an exception occurred then the provided error action is performed with the exception.- Parameters:
action- the action to be performederrorAction- the error action to be performed
-
orElseThrow
Returns the resolved value if a value was resolved and no exception occurred, otherwise throws the resolution exception back to the caller.- Returns:
- the resolved value if a value was resolved and no exception occurred
- Throws:
RuntimeException- if an exception occurred during resolution
-
orElseThrow
Returns the resolved value if a value was resolved and no exception occurred, otherwise wraps the resolution exception with the provided error message and throws back to the caller.- Parameters:
wrappingErrorMessage- additional context to add to the wrapped exception- Returns:
- the resolved value if a value was resolved and no exception occurred
- Throws:
RuntimeException- wrapping the resolution exception if an exception occurred during resolution
-
equals
-
hashCode
public int hashCode() -
toString
-