Package io.micrometer.spring.util
Class LambdaSafe.InvocationResult<R>
- java.lang.Object
-
- io.micrometer.spring.util.LambdaSafe.InvocationResult<R>
-
- Type Parameters:
R- the result type
- Enclosing class:
- LambdaSafe
public static final class LambdaSafe.InvocationResult<R> extends java.lang.ObjectThe result of a callback which may be a value,nullor absent entirely if the callback wasn't suitable. Similar in design toOptionalbut allows fornullas a valid value.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Rget()Return the result of the invocation ornullif the callback wasn't suitable.Rget(R fallback)Return the result of the invocation or the given fallback if the callback wasn't suitable.booleanhasResult()Return true if a result in present.static <R> LambdaSafe.InvocationResult<R>noResult()Return anLambdaSafe.InvocationResultinstance representing no result.static <R> LambdaSafe.InvocationResult<R>of(R value)Create a newLambdaSafe.InvocationResultinstance with the specified value.
-
-
-
Method Detail
-
hasResult
public boolean hasResult()
Return true if a result in present.- Returns:
- if a result is present
-
get
public R get()
Return the result of the invocation ornullif the callback wasn't suitable.- Returns:
- the result of the invocation or
null
-
get
public R get(R fallback)
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
public static <R> LambdaSafe.InvocationResult<R> of(R value)
Create a newLambdaSafe.InvocationResultinstance with the specified value.- Type Parameters:
R- the result type- Parameters:
value- the value (may benull)- Returns:
- an
LambdaSafe.InvocationResult
-
noResult
public static <R> LambdaSafe.InvocationResult<R> noResult()
Return anLambdaSafe.InvocationResultinstance representing no result.- Type Parameters:
R- the result type- Returns:
- an
LambdaSafe.InvocationResult
-
-