mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add methods
This commit is contained in:
@@ -302,6 +302,24 @@ public class BeanUtilTest {
|
||||
Assert.assertTrue(p3.getSlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copyPropertiesIgnoreNullTest() {
|
||||
SubPerson p1 = new SubPerson();
|
||||
p1.setSlow(true);
|
||||
p1.setName(null);
|
||||
|
||||
SubPerson2 p2 = new SubPerson2();
|
||||
p2.setName("oldName");
|
||||
|
||||
// null值不覆盖目标属性
|
||||
BeanUtil.copyProperties(p1, p2, CopyOptions.create().ignoreNullValue());
|
||||
Assert.assertEquals("oldName", p2.getName());
|
||||
|
||||
// null覆盖目标属性
|
||||
BeanUtil.copyProperties(p1, p2);
|
||||
Assert.assertNull(p2.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copyPropertiesBeanToMapTest() {
|
||||
// 测试BeanToMap
|
||||
|
Reference in New Issue
Block a user