Support for Value Objects

62 views
Skip to first unread message

Kurt Guenther

unread,
Jan 20, 2020, 12:41:39 PM1/20/20
to mapstruct-users

Is there a way to use Value objects with MapStruct?    

A value object in this case is a non-modifiable object which usually has 'all final attributes' or val types in Kotlin, so it needs to be constructed by passing in all the attributes. 


Kurt Guenther

unread,
Feb 13, 2020, 10:41:20 AM2/13/20
to mapstruct-users
Any ideas?? 

Christian

unread,
Feb 13, 2020, 1:02:51 PM2/13/20
to mapstru...@googlegroups.com

Hi Kurt,

Instantiation via constructor arguments is not yet supported, but with version 1.3 builder-support was added.

So you can create a builder that is able to instantiate your object and MapStruct could use this one, see the documentation: https://mapstruct.org/documentation/stable/reference/html/#mapping-with-builders

As you mentioned Kotlin you might find something valuable for you here:

* https://github.com/mapstruct/mapstruct-examples/tree/master/mapstruct-kotlin
* https://github.com/mapstruct/mapstruct/issues/1672


Best regards,

Christian

--
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/b2793e85-5c22-4d06-b2fe-3f72d38128c3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages