Implementing ignore mapping, issue #72

933 views
Skip to first unread message

Carsten Christensen

unread,
Apr 8, 2014, 9:30:50 AM4/8/14
to mapstru...@googlegroups.com

Hi


Regarding issue  'Allow to exclude a property from mapping #72'


Any hints on how you see this feature implmented, i might give it a shot, since i will need this rather soon. 

I want to be able to use unmappedTargetPolicy = ERROR, and at the same time i have som properties that will mapstruct is not able to map, hence i do the mapping in these special cases in an abstract class (could maybe be moved to using Decorators). But the then i need to override the mapping error with this ignore attribute.

Are you thinking ignore on both target and source, i.e., taget = 'xx', ignore = true, and source="xx", ignore=true.

I dont really know the mapstruct code so if you can point me in any direction i'll be most appreciated.

Best regards
Carsten Christensen

Gunnar Morling

unread,
Apr 8, 2014, 9:53:18 AM4/8/14
to Carsten Christensen, mapstru...@googlegroups.com
Hi Carsten,

Great to hear that you're interested in contributing to the development of MapStruct.

Very generally speaking, MapStruct is a JSR 269 annotation processor. It reads the annotated interface(s), builds up an internal model representing the mapper(s) to generate and writes source files based on this model using FreeMarker templates. You can find some hints for getting started with MapStruct development at [1], in particular check out the referenced JavaDoc pages.

I think the way to go would be to add an attribute "ignore" to the @Mapping annotation. If it's set to true, the property identified via "source" (or "target") would not be propagated. To exclude a property from being mapped, you'd have to avoid the creation of a PropertyMapping object based on this "ignore" attribute (see MapperCreationProcessor#getBeanMappingMethod() and related methods).
I hope this helps to get you started; in case you need any further assistance, just let me know.

--Gunnar





--
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 post to this group, send email to mapstru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages