79449802

Date: 2025-02-18 22:56:00
Score: 0.5
Natty:
Report link

You could also create a "wrapper" method (getFirstElement) on the SourceObject:

public class SourceObject {
public ArrayList<ListObject> list = new ArrayList<ListObject>();

public SourceObject() {
    list.add(new ListObject());
}

public getFirstElement(){
    return list.get(0);
}

So in your initial mapping you can say:

@Mappings({
    @Mapping(target="details.forename", source="firstElement.details.forename"),
    @Mapping(target="details.surname", source="firstElement.details.surname"),
})
DestinationObject toDestination(SourceObject source);
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Hugo Martinez