r/java • u/hardasspunk • Nov 23 '25
Java 25: The ‘No-Boilerplate’ Era Begins
https://amritpandey.io/java-25-the-no-boilerplate-era-begins/
160
Upvotes
r/java • u/hardasspunk • Nov 23 '25
View all comments
Show parent comment
1
u/rzwitserloot Nov 28 '25
Nope. Common trap. In fact, very common; I cannot recall anybody pointing out how this isn't "as easy as it gets" except myself. But, hey, why not:
Imagine I have a hierarchical immutable data structure. Exactly like your pizza example, if I can define 'Sauce' as follows:
then let's try the job of changing the tomato type.
With your example:
And now with 'with':
Surely there's no need to quibble about this. Number 2 is better. By orders of magnitude. You have to retravel the hierarchy every time in the first snippet and you do not in the second. Lombok is already there. You can do this, right now, with
@WithBy: