mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add ValueListHandler
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.bean;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.bean.copier.ValueProvider;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@@ -143,6 +144,18 @@ public class BeanUtilTest {
|
||||
Assert.assertEquals("sub名字", map.get("sub_name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanToMapWithAliasTest() {
|
||||
SubPersonWithAlias person = new SubPersonWithAlias();
|
||||
person.setAge(14);
|
||||
person.setOpenid("11213232");
|
||||
person.setName("测试A11");
|
||||
person.setSubName("sub名字");
|
||||
|
||||
Map<String, Object> map = BeanUtil.beanToMap(person);
|
||||
Assert.assertEquals("sub名字", map.get("aliasSubName"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanToMapWithLocalDateTimeTest() {
|
||||
final LocalDateTime now = LocalDateTime.now();
|
||||
@@ -270,6 +283,15 @@ public class BeanUtilTest {
|
||||
private Boolean slow;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SubPersonWithAlias extends Person {
|
||||
@Alias("aliasSubName")
|
||||
private String subName;
|
||||
// boolean参数值非isXXX形式
|
||||
private Boolean slow;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Person {
|
||||
|
Reference in New Issue
Block a user