Merge pull request !392 from 申劭明/14402K
This commit is contained in:
Looly 2021-08-06 01:48:43 +00:00 committed by Gitee
commit 217ac3f708
2 changed files with 17 additions and 0 deletions

View File

@ -155,6 +155,7 @@ public class MapProxy implements Map<Object, Object>, OptNullBasicTypeFromObject
final String fieldName = StrUtil.removePreAndLowerFirst(methodName, 3);
if (StrUtil.isNotBlank(fieldName)) {
this.put(fieldName, args[0]);
return proxy;
}
} else if ("equals".equals(methodName)) {
return this.equals(args[0]);

View File

@ -28,4 +28,20 @@ public class MapProxyTest {
Set<Entry<Object,Object>> entrys = mapProxy.entrySet();
Assert.assertFalse(entrys.isEmpty());
}
private interface Student {
Student setName(String name);
Student setAge(int age);
String getName();
int getAge();
}
@Test
public void classProxyTest() {
Student student = MapProxy.create(new HashMap<>()).toProxyBean(Student.class);
student.setName("小明").setAge(18);
Assert.assertEquals(student.getAge(), 18);
Assert.assertEquals(student.getName(), "小明");
}
}