mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
fix typeUtil
This commit is contained in:
@@ -446,4 +446,28 @@ public class BeanUtilTest {
|
||||
BeanUtil.setProperty(resultMap, "codeList[0].name", "张三");
|
||||
Console.log(resultMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanCopyTest(){
|
||||
final Station station = new Station();
|
||||
station.setId(123456L);
|
||||
|
||||
final Station station2 = new Station();
|
||||
|
||||
BeanUtil.copyProperties(station, station2);
|
||||
Assert.assertEquals(new Long(123456L), station2.getId());
|
||||
}
|
||||
|
||||
public static class Station extends Tree<Station, Long> {
|
||||
|
||||
}
|
||||
|
||||
public static class Tree<E, T> extends Entity<T> {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Entity<T>{
|
||||
private T id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,24 +60,23 @@ public class TypeUtilTest {
|
||||
|
||||
@Test
|
||||
public void getActualTypesTest(){
|
||||
final Type idType = TypeUtil.getActualType(
|
||||
Station.class,
|
||||
Tree.class,
|
||||
TypeUtil.getFieldType(Station.class, "id"));
|
||||
// 测试多层级泛型参数是否能获取成功
|
||||
Type idType = TypeUtil.getActualType(Level3.class,
|
||||
ReflectUtil.getField(Level3.class, "id"));
|
||||
|
||||
Assert.assertEquals(Long.class, idType);
|
||||
}
|
||||
|
||||
public static class Station extends Tree<Station, Long>{
|
||||
public static class Level3 extends Level2<Level3>{
|
||||
|
||||
}
|
||||
|
||||
public static class Tree<E, T> extends Entity<T>{
|
||||
public static class Level2<E> extends Level1<Long>{
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Entity<T>{
|
||||
public static class Level1<T>{
|
||||
private T id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user