AbstractThe type of the product being built.
Protected_Internal flag to track if any builder mutations have been registered/executed.
Protected AbstractproductThe product instance being constructed by this builder. Must be initialized by the subclass.
Indicates whether the builder has performed/registered any modifications on the product.
Registers and immediately executes a modification function on the product.
Sets the builder's active state to true and returns the builder instance
for method chaining.
A callback function that receives the current product and performs modifications on it.
The builder instance (this) to allow fluent method chaining.
An abstract base class implementing the Builder design pattern.
The Builder pattern is a creational design pattern that lets you construct complex objects step-by-step. The pattern allows you to produce different types and representations of an object using the same construction code.
Subclasses should extend this class, define their concrete
productproperty, and implement chainable methods using the register method.Example
Builder with external input product
Example
Builder with fresh product