*/
public class ManualListMapper implements Mapper {
public Object fromEntity(final Object entity) {
final Person person = (Person) entity;
final PersonWithHistoryDTO dto = new PersonWithHistoryDTO();
if (person.getPreviousAddresses() != null) {
dto.setPreviousAddresses(new ArrayList<AddressDTO>());
for (final Address address : person.getPreviousAddresses()) {
dto.getPreviousAddresses().add(fromAddress(address));
}
}
if (person.getName() != null) {
dto.setFirstName(person.getName().getFirstname());
dto.setLastName(person.getName().getSurname());
}
if (person.getCurrentAddress() != null) {
final Address address = person.getCurrentAddress();
final AddressDTO addressDTO = fromAddress(address);
dto.setCurrentAddress(addressDTO);
}
dto.setId(person.getId());
return dto;
}