我有两个pojo。
public class Pojo1 implements Serializable {
private static final long serialVersionUID = 1302290920579795856L;
private Long id;
private String idNumber;
private String vendorNumber;
private Date expires;
// Getters and setters for each one
}
public class Pojo2 implements Serializable {
private static final long serialVersionUID = 1302290920579795856L;
private Long id;
private String idNumber;
private String vendorNumber;
private Date expires;
private String otherData;
// Getters and setters for each one
}
是否有 Java API 可用于从 Pojo2 自动创建 Pojo1?
IE:
Pojo1 newPojo1 = SomeLibrary.fromPojoWithLikeNamedFields(pojo2);
// newPojo1 now has all the fields that had the same name from pojo2