Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0
-
None
-
Java 1.5+
Description
I propose the addition of a Builder<T> interface that can be used to identify a class as a builder of a concrete type of object. The interface would provide the following method:
T build();
There are many examples of classes that define a build() method, including BasicThreadFactory.Builder. By implementing this interface, the classes would explicitly indicate the object type they are capable of building. Furthermore, the interface can provide documentation on the best approach to implementing builder classes.
I additionally suggest that the existing builder classes (CompareToBuilder, EqualsBuilder, HashCodeBuilder, and ToStringBuilder) implement this interface. No other changes would need to be made, since the class's build() method would only need to return the result of the current "build" method for each of those classes.