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
Sometimes we obtain model from db, we want to change some params value of this. From the characteristics of functional programming, we hope that objects have immutability and no side effects. So I often use @with@builder(toBuilder = true) of Lombok.
When I change a value of model. Such as change name, I will.... var newModel = model.withName(newName);
When I change multi values of model. Such as change name、address、profession, I will.... var newModel = model.toBuilder.name(newName).address(newAddress).profession(newProfession).build();
return a new model. I don't worry about data conflicts or data being overwritten.
I hope generated pojos can support @with @builder(toBuilder = true).
Create an immutable object & edit pojos can be more functional.
The text was updated successfully, but these errors were encountered: