Orika - list to list conversion

Bick picture Bick · Feb 13, 2014 · Viewed 11.3k times · Source

This is probably an easy one, but I cant find it in the docs. I have a person class

class BasicPerson {
   private String name;
   private int age;
   private Date birthDate;
   // getters/setters omitted
}

and a list of it

ArrayList<Person>

I want to change them to change them to

ArrayList<PersonDTO>

but with out an explicit loop. Is there a way to use MapperFacade.map for a list to list one line conversion ?

Answer

Andr&#233; picture André · Feb 13, 2014

It has this functionality built-in. Did you tried using the method

List<D> ma.glasnost.orika.impl.ConfigurableMapper.mapAsList(Iterable<S> source, Class<D> destinationClass)?

I tried to find a updated version of the Javadoc, but here is one of the 1.3.5. The current version is 1.4.5. MapperFacade Class