public class LambdaFactory extends Object
| Modifier and Type | Method and Description |
|---|---|
static <F> F |
build(Class<F> functionInterfaceType,
Class<?> declaringClass,
String methodName,
Class<?>... paramTypes)
构建Lambda
{@code
class Something {
private Long id;
private String name;
// ...
|
static <F> F |
build(Class<F> functionInterfaceType,
Executable executable)
根据提供的方法或构造对象,构建对应的Lambda函数
调用函数相当于执行对应的方法或构造 |
static <F> F |
build(Class<F> functionInterfaceType,
Executable executable,
Class<?> declaringClass)
根据提供的方法或构造对象,构建对应的Lambda函数
调用函数相当于执行对应的方法或构造 |
public static <F> F build(Class<F> functionInterfaceType, Class<?> declaringClass, String methodName, Class<?>... paramTypes)
class Something {
private Long id;
private String name;
// ... 省略GetterSetter方法
}
Function<Something, Long> getIdFunction = LambdaFactory.buildLambda(Function.class, Something.class, "getId");
BiConsumer<Something, String> setNameConsumer = LambdaFactory.buildLambda(BiConsumer.class, Something.class, "setName", String.class);
F - Function类型functionInterfaceType - 接受Lambda的函数式接口类型declaringClass - 声明方法的类的类型methodName - 方法名称paramTypes - 方法参数数组public static <F> F build(Class<F> functionInterfaceType, Executable executable)
F - Function类型functionInterfaceType - 接受Lambda的函数式接口类型executable - 方法对象,支持构造器public static <F> F build(Class<F> functionInterfaceType, Executable executable, Class<?> declaringClass)
F - Function类型functionInterfaceType - 接受Lambda的函数式接口类型executable - 方法对象,支持构造器declaringClass - Executable声明的类,如果方法或构造定义在父类中,此处用于指定子类Copyright © 2025. All rights reserved.