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