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 TypeMethodDescriptionboolean
Gets the exception that may have occurred during resolution.static <T> Resolved<T>
failed
(RuntimeException reason) Factory method to create aResolved
when resolution fails.static <T> Resolved<T>
Factory method to create aResolved
when resolution fails.get()
Deprecated, for removal: This API element is subject to removal in a future version.int
hashCode()
void
ifResolved
(Consumer<? super T> action) Performs the given action with the resolved value if a value was resolved and no exception occurred.void
ifResolvedOrElse
(Consumer<? super T> action, Consumer<RuntimeException> errorAction) Performs the given action with the resolved value if a non-null
value was resolved and no exception occurred.static <T> Resolved<T>
of
(T value) Factory method to create aResolved
when resolution succeeds.Returns the resolved value if a value was resolved and no exception occurred, otherwise throws the resolution exception back to the caller.orElseThrow
(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 aResolved
when resolution succeeds.- Type Parameters:
T
- the type of the value- Parameters:
value
- the non-null
resolved value- Returns:
- a
Resolved
containing the resolved value
-
failed
Factory method to create aResolved
when resolution fails.- Type Parameters:
T
- the type of the value- Parameters:
reason
- the non-null
reason the resolution failed- Returns:
- a
Resolved
containing anIllegalArgumentException
with the reason for the failure
-
failed
Factory method to create aResolved
when resolution fails.- Type Parameters:
T
- the type of the value- Parameters:
reason
- the non-null
reason the resolution failed- Returns:
- a
Resolved
containing the reason for the failure
-
get
Deprecated, for removal: This API element is subject to removal in a future version.Usevalue()
insteadGets the optional resolved value.- Returns:
- an optional with the resolved value or empty if failed to resolve
-
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-null
value 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
-
value()
instead