mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
增加copyProperties重载,实现根据Class创建对象 并进行属性拷贝
This commit is contained in:
@@ -202,6 +202,20 @@ public class BeanUtilTest {
|
||||
Assert.assertTrue(set.contains("subName"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copyProperties(){
|
||||
SubPerson person = new SubPerson();
|
||||
person.setAge(14);
|
||||
person.setOpenid("11213232");
|
||||
person.setName("测试A11");
|
||||
person.setSubName("sub名字");
|
||||
SubPerson person1 = BeanUtil.copyProperties(person, SubPerson.class);
|
||||
Assert.assertEquals(14,person1.getAge());
|
||||
Assert.assertEquals("11213232",person1.getOpenid());
|
||||
Assert.assertEquals("测试A11",person1.getName());
|
||||
Assert.assertEquals("sub名字",person1.getSubName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copyPropertiesHasBooleanTest() {
|
||||
SubPerson p1 = new SubPerson();
|
||||
|
Reference in New Issue
Block a user