我有两个具有相同字段数和相同字段名称的类。唯一的不同是它们的字段类型。
我需要做的是从一个类中获取所有字段值并将它们放入另一个类中。
public class PersonA {
private String name;
private String family;
//here AddressDto package is com.test.project.employer
private AddressDto addressDto;
//here ContactInfo package is com.test.project.employer
private List<ContactInfo> contactInfo;
}
public class PersonB {
private String name;
private String family;
//here AddressDto package is com.test.project.customer
private AddressDto addressDto;
//here ContactInfo package is com.test.project.customer
private List<ContactInfo> contactInfo;
}
Run Code Online (Sandbox Code Playgroud)
外部 Dtos 内也可能有其他 Dtos 或带有自定义 Dtos 的地图,因此我需要管理所有要检查的字段,看看内部是否有其他 dto!
我已经完成的工作适用于 Java 类和原始类型,如 String、BigDecimal、int 等,但不适用于我的应用程序 dtos。
这是我的代码:
PersonA personA = new PersonA();
PersonB personB = new …Run Code Online (Sandbox Code Playgroud)