fix typeUtil

This commit is contained in:
Looly
2020-09-06 02:20:15 +08:00
parent 3e05c5b396
commit 784ad3e8f9
14 changed files with 269 additions and 125 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}