0

I have POJO with nested objects which i need to translate to a simple object with out nesting for example i have a Person and Address as below

public class Person {
     private String firstName;
     private String lastName;
     private Address address;
}  

public class Address {
    private String lineOne;
    private String lineTwo;
}

I need to translate Person to PersonFlat which looks like

public class PersonFlat {
     private String firstName;
     private String lastName;
     private String Address_lineOne;
     private String Address_lineTwo;
}  

is there any way where i can do xpath kind of extraction on the Person instance to get the Address.lineOne and Address.lineTwo using groovy metaClass ?

rajn
  • 180
  • 2
  • 13
  • Not sure what you mean, can you explain the format of what you'd like to do (that isn't working) – tim_yates Dec 19 '13 at 09:55
  • I have a Person POJO which has reference to Address POJO, i need to dynamically create a bean which is similart to PersonFlat POJO. Since in groovy we can add properties on run time i can create the properties but to fetch the value from the nested pojo i was thinking of using GPath expressions which deals with nested POJOs – rajn Dec 19 '13 at 20:30

0 Answers0