I would like to see how is Builder pattern used in real world applications/APIs. The examples I found are all pizzas, cakes, cars et cetera (plus the parser example from the GoF
Builder pattern is used in javax.json.Json
and javax.json.JsonBuilder
classes while building Json objects.
Good explanation is at http://www.programcreek.com/java-api-examples/index.php?api=javax.json.JsonObjectBuilder and also check out its official documentation.
JsonObjectBuilder b = Json.createObjectBuilder().
add( "report", Json.createObjectBuilder().
add( "reportId", reportId ).
add( "title", title ).
add( "subtitle", subTitle == null ? "" : subTitle ).
add( "created", created.toString() ).
add( "description", description == null ? "" : description ).
add( "data", report )
);
return b.build();