mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Merge pull request !392 from 申劭明/14402K
This commit is contained in:
commit
217ac3f708
@ -155,6 +155,7 @@ public class MapProxy implements Map<Object, Object>, OptNullBasicTypeFromObject
|
|||||||
final String fieldName = StrUtil.removePreAndLowerFirst(methodName, 3);
|
final String fieldName = StrUtil.removePreAndLowerFirst(methodName, 3);
|
||||||
if (StrUtil.isNotBlank(fieldName)) {
|
if (StrUtil.isNotBlank(fieldName)) {
|
||||||
this.put(fieldName, args[0]);
|
this.put(fieldName, args[0]);
|
||||||
|
return proxy;
|
||||||
}
|
}
|
||||||
} else if ("equals".equals(methodName)) {
|
} else if ("equals".equals(methodName)) {
|
||||||
return this.equals(args[0]);
|
return this.equals(args[0]);
|
||||||
|
@ -28,4 +28,20 @@ public class MapProxyTest {
|
|||||||
Set<Entry<Object,Object>> entrys = mapProxy.entrySet();
|
Set<Entry<Object,Object>> entrys = mapProxy.entrySet();
|
||||||
Assert.assertFalse(entrys.isEmpty());
|
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(), "小明");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user