类 LambdaSafe
- java.lang.Object
- org.springframework.boot.util.LambdaSafe
public final class LambdaSafe extends Object
Utility that can be used to invoke lambdas in a safe way. Primarily designed to help support generically typed callbacks whereclass cast exceptions
need to be dealt with due to class erasure.- 从以下版本开始:
- 2.0.0
嵌套类概要
嵌套类 修饰符和类型 类 说明 static class
LambdaSafe.Callback<C,A>
Represents a single callback that can be invoked in a lambda safe way.static class
LambdaSafe.Callbacks<C,A>
Represents a collection of callbacks that can be invoked in a lambda safe way.static class
LambdaSafe.InvocationResult<R>
The result of a callback which may be a value,null
or absent entirely if the callback wasn't suitable.
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static <C,A>
LambdaSafe.Callback<C,A>callback(Class<C> callbackType, C callbackInstance, A argument, Object... additionalArguments)
Start a call to a single callback instance, dealing with common generic type concerns and exceptions.static <C,A>
LambdaSafe.Callbacks<C,A>callbacks(Class<C> callbackType, Collection<? extends C> callbackInstances, A argument, Object... additionalArguments)
Start a call to callback instances, dealing with common generic type concerns and exceptions.
方法详细资料
callback
public static <C,A> LambdaSafe.Callback<C,A> callback(Class<C> callbackType, C callbackInstance, A argument, Object... additionalArguments)
Start a call to a single callback instance, dealing with common generic type concerns and exceptions.- 类型参数:
C
- the callback typeA
- the primary argument type- 参数:
callbackType
- the callback type (afunctional interface
)callbackInstance
- the callback instance (may be a lambda)argument
- the primary argument passed to the callbackadditionalArguments
- any additional arguments passed to the callback- 返回:
- a
LambdaSafe.Callback
instance that can be invoked.
callbacks
public static <C,A> LambdaSafe.Callbacks<C,A> callbacks(Class<C> callbackType, Collection<? extends C> callbackInstances, A argument, Object... additionalArguments)
Start a call to callback instances, dealing with common generic type concerns and exceptions.- 类型参数:
C
- the callback typeA
- the primary argument type- 参数:
callbackType
- the callback type (afunctional interface
)callbackInstances
- the callback instances (elements may be lambdas)argument
- the primary argument passed to the callbacksadditionalArguments
- any additional arguments passed to the callbacks- 返回:
- a
LambdaSafe.Callbacks
instance that can be invoked.