-
-
Notifications
You must be signed in to change notification settings - Fork 922
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
Inconsistent use of clearing collections in case of update methods. #1142
Comments
Will the collection.clear() be added to the generated update method implementation for the ADDER_PREFERRED strategy? |
I'm reiterating some issues.. I see there's a difference. Although I am thinking whether we should access a getter when handling an adder method... @filiphr : WDYT? |
This is a tough one @sjaakd. I also had the same question last week. I would say if you are using an adder strategy we should not touch the getter. It might even be possible that the adder returns an immutable collection that will throw an exception if we clear it, so I wouldn't go there 😄 |
Ok.. I'll close this one.. But we clear collections also in the regular case. Should we leave that as is? |
I think that in the regular case it is OK. The reason is that we are using the getter to add to the collection, so we can clear it. If we can't clear it we also can't add to it (at least that is my reasoning) |
Agreed. But do we add this reasoning somewhere..? FAQ? |
Perhaps in the documentation? |
Good idea.. I'll open op a pr for that.. |
In Update existing bean instances we currently have
Maybe we need to add about the adders here |
Hmmm. Immutable? I don't think we have adders for maps.. |
* mapstruct#1142 update documentation * mapstruct#1142 comment
when using
ADDER_PREFERRED
the following update method is generated:It doesn't clear the collection. This is not consistent with other
CollectionMappingStrategie
'sicw update methods.
The text was updated successfully, but these errors were encountered: