This commit is contained in:
Looly 2022-06-21 18:18:21 +08:00
parent e74b99a558
commit 891e36d888

View File

@ -0,0 +1,25 @@
package cn.hutool.core.bean;
import lombok.Data;
import org.junit.Assert;
import org.junit.Test;
public class IssueI5DDZXTest {
@Test
public void copyPropertiesTest() {
// 对于final字段private由于没有提供setter方法是无法实现属性赋值的如果设置为public即可
final TeStudent student = new TeStudent("Hutool");
final TePerson tePerson = BeanUtil.copyProperties(student, TePerson.class);
Assert.assertEquals("Hutool", tePerson.getName());
}
@Data
static class TeStudent {
private final String name;
}
@Data
static class TePerson {
public final String name;
}
}