From the Definition, “Separate the construction of a complex object from its representation so that the same construction process can create different representations.” Builder pattern builds a product and it needs a direction with the help of a concrete building.
From the Quartz scheduler, we can find real-time examples like JobBuilder, TriggerBuilder, DateBuilder, etc., which can be found here Quartz Scheduler.
In springboot you can find builder pattern in multiple places.
Example:
interface DocumentBuilder{
void addTitle();
void addParagraph();
}
void createDocument(DocumentBuilder dBuilder) {
dBuilder.addTitle("Builder pattern application..");
dBuilder.addParagraph("Is the Builder Pattern restricted...");
dBuilder.addParagraph("The builder pattern implementation ...");
}
class WordDocumentBuilder implements DocumentBuilder {
..........
WordDocument getResult();
}
WordDocumentBuilder b = new WordDocumentBuilder();
createDocument(b);
WordDocument dom = b.getResult();
We can build any kind of document by creating a concrete object to each product.