As per the requirement, I have parsed an XML file and set data into these two DTO classes:
public class DetailsDTO implements java.io.Serializable {
private String userid;
private String accountnum;
private Customer customer;
// setters and getters
public class Customer implements Serializable
{
private String street;
private String country;
// setters and getters
After adding data of the Customer class to DetailsDTO, I added this DetailsDTO to an ArrayList as shown:
List list = new ArrayList();
// and added these DetailsDTO class to an ArrayList
list.add(detailsDTO)
Now there is a Master DTO called as WholeDetails which consists of all variables defined in various DTO classes as shown.
class WholeDetails
{
private String userid;
private String accountnum;
private String street;
private String country;
}
Now, as you see, all the data is aviable within the ArrayList.
How can I extract the contents from ArrayList and map it to the WholeDetails?
You will have to do the mapping e.g.
If you like it to be more short you could create an adapter class that maps the
DetailsDTOto theWholeDetailsDTOand add the result object to the list