mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
add method
This commit is contained in:
parent
9e06536767
commit
da40e42124
@ -1,7 +1,6 @@
|
||||
package cn.hutool.core.lang.func;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.lang.SimpleCache;
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
@ -109,27 +108,28 @@ public class LambdaUtil {
|
||||
|
||||
/**
|
||||
* 通过{@link SerializedLambda#getInstantiatedMethodType()}获取lambda实现类<br>
|
||||
* 在使用{@link #getImplClass(Func0)}获取实现类的时候,如果传入的是父类方法引用,会返回父类导致问题<br>
|
||||
* 在使用{@link #getImplClass(Func0)}获取实现类的时候,如果传入的是父类方法引用,会返回父类,导致问题<br>
|
||||
* 此类通过方法的名称,截取出类名
|
||||
*
|
||||
* @param func lambda
|
||||
* @param <P> 类型
|
||||
* @return lambda实现类
|
||||
* @since 5.8.0
|
||||
*/
|
||||
public static <P> Class<P> getInstantiatedClass(Func0<?> func) {
|
||||
final String instantiatedMethodType = resolve(func).getInstantiatedMethodType();
|
||||
Console.log(instantiatedMethodType);
|
||||
return ClassUtil.loadClass(StrUtil.sub(instantiatedMethodType, 2, StrUtil.indexOf(instantiatedMethodType, ';')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过{@link SerializedLambda#getInstantiatedMethodType()}获取lambda实现类<br>
|
||||
* 在使用{@link #getImplClass(Func1)}获取实现类的时候,如果传入的是父类方法引用,会返回父类导致问题<br>
|
||||
* 在使用{@link #getImplClass(Func1)}获取实现类的时候,如果传入的是父类方法引用,会返回父类,导致问题<br>
|
||||
* 此类通过方法的名称,截取出类名
|
||||
*
|
||||
* @param func lambda
|
||||
* @param <P> 类型
|
||||
* @return lambda实现类
|
||||
* @since 5.8.0
|
||||
*/
|
||||
public static <P> Class<P> getInstantiatedClass(Func1<P, ?> func) {
|
||||
final String instantiatedMethodType = resolve(func).getInstantiatedMethodType();
|
||||
|
Loading…
x
Reference in New Issue
Block a user