This commit is contained in:
Looly
2024-10-24 18:59:50 +08:00
parent 6d7cf5dddf
commit 0449db7aa9

View File

@@ -0,0 +1,32 @@
package cn.hutool.core.bean;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class IssueIAYGT0Test {
/**
* BeanUtil.setProperty默认调用的是BeanPath方法在设置值时使用BeanUtil.setFieldValue这个方法。
* 此方法默认直接给字段赋值。
* 这里确实存在一定的歧义性,但是考虑到兼容性,不做处理。
*/
@Test
void setPropertyTest() {
Cat cat = new Cat();
BeanUtil.setProperty(cat, "name", "Kitty");
Assertions.assertEquals("Kitty", cat.getName());
}
static class Cat {
private String name;
public void setName(String name) {
this.name = "Red" + name;
}
public String getName() {
return name;
}
}
}