Reputation: 111
I have written a MapStruct mapper which has two methods with the @AfterMapping
annotation. Depending on the context, I want only one of these methods to be executed before the end of the mapping.
With regard to this, the MapStruct documentation states:
All after-mapping methods that can be applied to a mapping method will be used.
@Qualifier / @Named
can be used to filter the methods to use.
Regarding @Named
, the documentation contains a good example on how to use this annotation in order to perform two different kinds of mappings for a bean property. But I do not understand how to adapt this kind of distinction to my two after-mapping methods.
Upvotes: 2
Views: 6596
Reputation: 4150
You can specify the qualifier in the @BeanMapping annotation in order to make it applicable to life cycle method. Note: I recently fixed an issue in this area on the master. Don't think that's released already. Forgot the exact issue (not able to look it up currently)
Upvotes: 2