[jira] Created: (LANG-601) Add Builder Interface / Update Builders to Implement It

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (LANG-601) Add Builder Interface / Update Builders to Implement It

Michael Osipov (Jira)
Add Builder Interface / Update Builders to Implement It
-------------------------------------------------------

                 Key: LANG-601
                 URL: https://issues.apache.org/jira/browse/LANG-601
             Project: Commons Lang
          Issue Type: New Feature
          Components: lang.builder.*
    Affects Versions: 3.0
         Environment: Java 1.5+
            Reporter: Michael Wooten
            Priority: Minor
             Fix For: 3.0


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.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LANG-601) Add Builder Interface / Update Builders to Implement It

Michael Osipov (Jira)

     [ https://issues.apache.org/jira/browse/LANG-601?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Wooten updated LANG-601:
--------------------------------

    Attachment: commons-lang-builder.patch

The attached patch was created with Eclipse. The patch includes a new Builder interface in the builder package, and also updates all of the *Builder classes to implement this new interface. Additional test cases were added to test that the build() methods return the appropriate results.

> Add Builder Interface / Update Builders to Implement It
> -------------------------------------------------------
>
>                 Key: LANG-601
>                 URL: https://issues.apache.org/jira/browse/LANG-601
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.builder.*
>    Affects Versions: 3.0
>         Environment: Java 1.5+
>            Reporter: Michael Wooten
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: commons-lang-builder.patch
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> 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.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (LANG-601) Add Builder Interface / Update Builders to Implement It

Michael Osipov (Jira)
In reply to this post by Michael Osipov (Jira)

     [ https://issues.apache.org/jira/browse/LANG-601?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed LANG-601.
------------------------------

    Resolution: Fixed

Thanks Michael.

I think it's a great idea.

svn ci -m "Adding Builder interface, and refactoring the builder classes and BasicThreadFactory to implement this interface. Patch from Michael Wooten in LANG-601"
Adding         src/main/java/org/apache/commons/lang3/builder/Builder.java
Sending        src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
Sending        src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
Sending        src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
Sending        src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java
Sending        src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
Sending        src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
Sending        src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
Sending        src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
Sending        src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
Transmitting file data ..........
Committed revision 925674.


> Add Builder Interface / Update Builders to Implement It
> -------------------------------------------------------
>
>                 Key: LANG-601
>                 URL: https://issues.apache.org/jira/browse/LANG-601
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.builder.*
>    Affects Versions: 3.0
>         Environment: Java 1.5+
>            Reporter: Michael Wooten
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: commons-lang-builder.patch
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> 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.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.