You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simple improvement could be if Immutables would generate update-methods along with withers to allow transforming nested objects more cleanly. Basic update-method signature for a String foo-property in ImmutableBar -class would be:
Currently updaters can be written by hand to the template class / interface if needed, but I see no reason why they could not be generated.
Also Optional (and Vavr Option etc.) could be taken account and offer an updater method which would transform the value only if it is present but this feature is not a must.
Chaining and doing this for multiple fields is of course inefficient but nothing prevents abusing withers in the same way.
The text was updated successfully, but these errors were encountered:
Thank you for the feature request. The idea is good, maybe something like that was planned before, but we always tried to keep number of generated methods minimal. Ideally, we would have some sort of extensibility mechanism to add methods like these. The encodings (https://immutables.github.io/encoding.html) are a kind of extensibility I'm talking about, but these are per type, not applicable to any attribute. Indeed, this can be activated by a style flag in a form of naming pattern, empty by default - disabled (default "", can be "map*" -> giving mapFoo method for foo attribute. Need to think how much changes we need if implemented in a "good old way".
Currently transforming Immutables-generated objects requires to write rather clumsy code.
And it gets worse with nested objects.
Simple improvement could be if Immutables would generate update-methods along with withers to allow transforming nested objects more cleanly. Basic update-method signature for a
String foo
-property in ImmutableBar -class would be:Which would allow to write:
Or if the
foo
-property would be another immutables -generated object instead of String:Currently updaters can be written by hand to the template class / interface if needed, but I see no reason why they could not be generated.
Also Optional (and Vavr Option etc.) could be taken account and offer an updater method which would transform the value only if it is present but this feature is not a must.
Chaining and doing this for multiple fields is of course inefficient but nothing prevents abusing withers in the same way.
The text was updated successfully, but these errors were encountered: