Package org.springframework.boot.util
Class LambdaSafe.InvocationResult<R>
java.lang.Object
org.springframework.boot.util.LambdaSafe.InvocationResult<R>
- Type Parameters:
R
- the result type
- Enclosing class:
- LambdaSafe
The result of a callback which may be a value,
null
or absent entirely if
the callback wasn't suitable. Similar in design to Optional
but allows for
null
as a valid value.-
Method Summary
Modifier and TypeMethodDescriptionget()
Return the result of the invocation ornull
if the callback wasn't suitable.Return the result of the invocation or the given fallback if the callback wasn't suitable.boolean
Return true if a result in present.static <R> LambdaSafe.InvocationResult<R>
noResult()
Return anLambdaSafe.InvocationResult
instance representing no result.static <R> LambdaSafe.InvocationResult<R>
of
(R value) Create a newLambdaSafe.InvocationResult
instance with the specified value.
-
Method Details
-
hasResult
public boolean hasResult()Return true if a result in present.- Returns:
- if a result is present
-
get
Return the result of the invocation ornull
if the callback wasn't suitable.- Returns:
- the result of the invocation or
null
-
get
Return the result of the invocation or the given fallback if the callback wasn't suitable.- Parameters:
fallback
- the fallback to use when there is no result- Returns:
- the result of the invocation or the fallback
-
of
Create a newLambdaSafe.InvocationResult
instance with the specified value.- Type Parameters:
R
- the result type- Parameters:
value
- the value (may benull
)- Returns:
- an
LambdaSafe.InvocationResult
-
noResult
Return anLambdaSafe.InvocationResult
instance representing no result.- Type Parameters:
R
- the result type- Returns:
- an
LambdaSafe.InvocationResult
-