add ValueListHandler

This commit is contained in:
Looly
2020-02-29 15:06:56 +08:00
parent df96ef1a29
commit 1ed2ec9dc4
9 changed files with 128 additions and 45 deletions

View File

@@ -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 {