Details
-
New Feature
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.7.0
-
None
-
None
Description
The Builder pattern as described by the gang of four and general implementations across multiple blogs and source packages creates a complex pattern when a method is called. That method specified in the pattern description is "getResult", however the review of several blogs and implementations indicate that "build", "getX" "toX" are all popular names for the production method.
In Java the Supplier interface defines a producer of X and stipulates that every time the production method is called an instance of X must be returned. It does allow for the same instance to be returned for every call.
Thus a Builder is a customization of the Supplier. As commons strives to utilize the JRE patterns over custom patterns, it makes sense that all Builders should implement Supplier.
Therefore this change is to have all Builders
- implement Supplier and add a get() method (if not already present)
- have the current producer method delegate to the get() method
- mark the current producer method as deprecated with a note to use get.