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
Feature/114 collection copying only when changed #118
Feature/114 collection copying only when changed #118
Conversation
I just did an experiment. I don't think the shim classes are needed. Here's what ensureListMutable could look like:
The idea is to return an anonymous nested class which takes advantage of the fact that |
That'd work, too. But I think it hides its meaning quite well (at least I wouldn't get the purpose from looking at the code). Maybe it would make it even more clear if the classes were named, e.g. |
I'd rather not introduce yet more types in the builder class as it's getting very complex already. While this might be harder to read it's much easier to maintain as it's all located within the method. So, this is my preference. |
I tried it with the inner anonymous class, technically of course it works, but I'm getting a problem with jacoco then: |
In case there is not a smart way to circumvent that coverage thing, I'd suggest to just call the shim methods in the constructor then. If another constructor was created for whatever reason it would just have to be made sure, that the shim methods were called there as well. |
Farg - I forgot about Jacoco 🤦🏻 OK - then let's stay with your change. However, the class names need to be added to |
Here you go! Out of curiosity: why do you prefer having the names of internal/private classes configurable? |
The builder classed can be subclassed. So, this is more for consistency than anything at this point. Maybe we should consider removing the configurable names for private classes. |
Looks good - thank you. Please squash to a single commit and I'll merge. |
7699796
to
2db2f1a
Compare
@Randgalt ready to merge 🎉 |
2db2f1a
to
84c5300
Compare
For #114 again.
Instead of using explicit booleans to track if a collection was changed I track it by the type of the collection.
For that, I added custom mutable private collections (subclassing
ArrayList
,HashSet
, andHashMap
) to the builder. This makes it explicitly known for us whether it's "our" mutable collection or if it comes from the outside.