I have a situation where I use a builder pattern for constructing an object. Best example to give is the pizza code
public class Pizza {
private int size;
pr
I think it could help someone in the future, but what about Copy constructor thou?
It will not break a contract of the immutability of an object and you will have an option to get a Pizza
with different property values.
So you can basically use two approaches:
Pizza.Builder(pizza).cheese(cheese).build()
Pizza.from(pizza).cheese(cheese).build()
as Akash Srivastava suggestedBoth approaches basically expecting a copy constructor of Pizza
or even feeding newly created builder
instance from pizza
parameter properties.