Deep Copy of Objects

229 views
Skip to first unread message

Kurt Guenther

unread,
Jan 20, 2020, 12:13:33 PM1/20/20
to mapstruct-users

We've been using MapStruct in our project.   Great tool, so thank you to everybody that contributed. 

Question:  we've been hand coding deep copies of object graphs, but this seems like a use case that is very similar to MapStruct's core use cases.   Is this supported? 

Gunnar Morling

unread,
Jan 20, 2020, 12:25:21 PM1/20/20
to Kurt Guenther, mapstruct-users
Hi,

It depends a bit on what exactly you mean by "deep copy", but
MapStruct definitely supports mapping nested object graphs. You'd
declare a mapping method for each pair of types in the source/target
graphs, and when figuring out that FooSource#bar needs to be mapped to
FooTarget#bar, MapStruct will generate an invocation of the
SourceBar-to-TargetBar mapping method.

--Gunnar


Am Mo., 20. Jan. 2020 um 18:13 Uhr schrieb Kurt Guenther
<kurtwg...@gmail.com>:
>
>
> We've been using MapStruct in our project. Great tool, so thank you to everybody that contributed.
>
> Question: we've been hand coding deep copies of object graphs, but this seems like a use case that is very similar to MapStruct's core use cases. Is this supported?
>
> --
> You received this message because you are subscribed to the Google Groups "mapstruct-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mapstruct-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mapstruct-users/ceaf5f1b-5d03-49f2-b300-e7d03cd76010%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages