我有嵌套对象的POJO,我需要将其转换为一个没有嵌套的简单对象 例如,我有一个人和地址如下
public class Person {
private String firstName;
private String lastName;
private Address address;
}
public class Address {
private String lineOne;
private String lineTwo;
}
我需要将Person翻译成PersonFlat,看起来像
public class PersonFlat {
private String firstName;
private String lastName;
private String Address_lineOne;
private String Address_lineTwo;
}
有什么方法可以在Person实例上进行xpath类型的提取,以使用groovy metaClass获取Address.lineOne和Address.lineTwo?