LambdaHelper
# LambdaHelper
LambdaHelper
可以解析lambda
例如可以通过lambda获取其信息
LambdaExecutable lambdaExecutable = LambdaHelper.resolve((Serializable & BiConsumer<Integer[][], Integer>) (i, a) -> {});
System.out.println(lambdaExecutable);
// LambdaExecutable{
// executable=private static void io.github.vampireachao.stream.core.lambda.LambdaHelperTest.lambda$testResolve$9b6dfab2$1(java.lang.Integer[][],java.lang.Integer),
// instantiatedTypes=[class [[Ljava.lang.Integer;, class java.lang.Integer],
// parameterTypes=[class [[Ljava.lang.Integer;, class java.lang.Integer],
// returnType=void,
// name='lambda$testResolve$9b6dfab2$1',
// clazz=class io.github.vampireachao.stream.core.lambda.LambdaHelperTest,
// lambda=SerializedLambda[capturingClass=class io.github.vampireachao.stream.core.lambda.LambdaHelperTest, functionalInterfaceMethod=java/util/function/BiConsumer.accept:(Ljava/lang/Object;Ljava/lang/Object;)V, implementation=invokeStatic io/github/vampireachao/stream/core/lambda/LambdaHelperTest.lambda$testResolve$c70a867a$1:([[Ljava/lang/Integer;Ljava/lang/Integer;)V, instantiatedMethodType=([[Ljava/lang/Integer;Ljava/lang/Integer;)V, numCaptured=0],
// proxy=null
// }
而且其在idea
的debug
模式下,在Evaluate
调试窗口声明的lambda
也可以被解析
# 拓展lambda
使用SerCons.multi
,可以让你的forEach
支持多个lambda
操作
import static io.github.vampireachao.stream.core.lambda.function.SerCons.multi;
Arrays.asList("vampire", "a chao").forEach(multi(
System.out::println,
System.err::println,
i -> System.out.println(i.equals("vampire"))
));
看不懂?没关系,戳我学习 (opens new window)
上次更新: 2024/03/29, 09:17:32