I have a couple of target objects like so:
class TargetParent {
int id;
... other scalar fields
List<TargetChild> children;
}
class TargetChild {
... scalar fields
}
However, in the source object, for complicated reasons the equivalent parent object doesn't have children, instead that comes from a separate map, like so:
class SourceParent {
int id;
... other scalar fields
}
class SourceChild {
... scalar fields
}
Map<Integer /* parent.id */, List<SourceChild>> parentToChildrenMap;
What's the cleanest way to write a mapstruct mapper from List<SourceParent> + parentToChildrenMap
to List<TargetParent>
using mapstruct? Essentially I'd like mapstruct to "zip" the source list and map together into a single target list, without having to write too much mapping code myself.