New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify documentation about Condition for update mappings #2715
Comments
Thank you for reporting this. First off, the reason for the inconsistency can be explained because primitives by design in java cannot be I believe the documentation will need to be updated here to include the else statement, because the
In case of conditions we then get the following: setting the |
Thanks for the reply, I've just came back to office and tested that I was aware that primitive can't be null but it wasn't the main reason why I considered it inconsistent. The real reason/problem is actually using setter at all for objects while for primitives it's skipped. It leads to dichotomy where object are set to their de facto default value while primitives aren't touched (int can be set to it's 'default' ie. 0). I'm still quite the beginner when it comes to mapstruct but if I could chose I would skip else statement every time by default and activate it by some setting, preferably no |
Thanks for the more detailed explanation of your expectations, we will take changing the default strategy into consideration for the 2.0.0 release. Changing this would be a breaking change, therefor not possible with the minor release builds we are doing now. Also reopening so we can use this issue to fix the documentation :) |
Just in case I faced the same issue and the |
When using condition (regardless of the way it has been qualified) with @MappingTarget generated code assign
null
(ie. default value) in else block although news, documentation and their examples state that mapping will be skipped if condition isn't met. Moreover it doesn't generate any else statement when operating on primitives making it inconsistent.Tested on both MapStruct 1.5.0.Beta1 and Beta2.
Here is code I've used to produce this behaviour:
And here is the result of generation:
The text was updated successfully, but these errors were encountered: