mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
修复ClassUtil.getTypeArgument() 获取泛型存在null问题
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Issue3516Test {
|
||||
|
||||
@Test
|
||||
public void getTypeArgumentTest() {
|
||||
final Type typeArgument = TypeUtil.getTypeArgument(Demo.class, 0);
|
||||
Assert.assertEquals(B.class, typeArgument);
|
||||
}
|
||||
|
||||
static class Demo implements A2B{
|
||||
@Override
|
||||
public A apply(B arg0) {
|
||||
final A a = new A();
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
static class A {
|
||||
private String name;
|
||||
}
|
||||
|
||||
static class B {
|
||||
private String name;
|
||||
}
|
||||
|
||||
interface A2B extends Function<B, A> {
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user