You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Aldrin Leal (JIRA)" <ji...@apache.org> on 2006/10/10 01:23:19 UTC
[jira] Created: (LANG-283) Visitors for Builders
Visitors for Builders
---------------------
Key: LANG-283
URL: http://issues.apache.org/jira/browse/LANG-283
Project: Commons Lang
Issue Type: New Feature
Affects Versions: 2.2
Environment: Any
Reporter: Aldrin Leal
Priority: Trivial
While doing commons-lang stuff, I found the repetitive nature of
Builder stuff. Therefore, i decided to:
a) Create a SingleBuilder (for ToString / HashCode) and a
DualBuilder (CompareTo / Equals) interface, and make their classes
implementing;
b) Create a SingleBuilderVisitor and DualBuilderVisitor;
c) Do the proper wiring, while creating new constructors using the visitors;
d) Create new tests and ensuring javadoc plays nice along;
There's a patch attached in this e-mail, done against the latest
svn STABLE url for 2.2
(http://svn.apache.org/repos/asf/jakarta/commons/proper/lang/branches/LANG_2_2_X/)
There might be errors, but methinks it's a great idea to declare a
constant like this in your source code.
private static final EQUALS_VISITOR = new DualBuilderVisitor() {
public void visit(DualBuilder builder, Object lhs, Object rhs) {
Type lhsObj = (Type) lhs;
Type rhsObj = (Type) rhs;
builder.append(lhsObj.getId(),
rhsObj.getId()).append(lhsObj.getName(), rhsObj.getName());
}
};
And then, declare and instantiate builders like as, say:
public boolean equals(Object anotherObj) {
return new EqualsVisitor(EQUALS_VISITOR, this, anotherObj);
}
Please note this implementation, overrall, also lets you easily use
a single visitor for either equals and compareto, thus creating a
single point of management for all your
field-maintenance-in-value-objects-needs.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-283) Visitors for Builders
Posted by "Aldrin Leal (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-283?page=all ]
Aldrin Leal updated LANG-283:
-----------------------------
Attachment: visitors.patch
Patch for Visitor-like funcionality
> Visitors for Builders
> ---------------------
>
> Key: LANG-283
> URL: http://issues.apache.org/jira/browse/LANG-283
> Project: Commons Lang
> Issue Type: New Feature
> Affects Versions: 2.2
> Environment: Any
> Reporter: Aldrin Leal
> Priority: Trivial
> Attachments: visitors.patch
>
>
> While doing commons-lang stuff, I found the repetitive nature of
> Builder stuff. Therefore, i decided to:
> a) Create a SingleBuilder (for ToString / HashCode) and a
> DualBuilder (CompareTo / Equals) interface, and make their classes
> implementing;
> b) Create a SingleBuilderVisitor and DualBuilderVisitor;
> c) Do the proper wiring, while creating new constructors using the visitors;
> d) Create new tests and ensuring javadoc plays nice along;
> There's a patch attached in this e-mail, done against the latest
> svn STABLE url for 2.2
> (http://svn.apache.org/repos/asf/jakarta/commons/proper/lang/branches/LANG_2_2_X/)
> There might be errors, but methinks it's a great idea to declare a
> constant like this in your source code.
> private static final EQUALS_VISITOR = new DualBuilderVisitor() {
> public void visit(DualBuilder builder, Object lhs, Object rhs) {
> Type lhsObj = (Type) lhs;
> Type rhsObj = (Type) rhs;
> builder.append(lhsObj.getId(),
> rhsObj.getId()).append(lhsObj.getName(), rhsObj.getName());
> }
> };
> And then, declare and instantiate builders like as, say:
> public boolean equals(Object anotherObj) {
> return new EqualsVisitor(EQUALS_VISITOR, this, anotherObj);
> }
> Please note this implementation, overrall, also lets you easily use
> a single visitor for either equals and compareto, thus creating a
> single point of management for all your
> field-maintenance-in-value-objects-needs.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-283) Visitors for Builders
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-283?page=all ]
Henri Yandell updated LANG-283:
-------------------------------
Fix Version/s: 3.0
> Visitors for Builders
> ---------------------
>
> Key: LANG-283
> URL: http://issues.apache.org/jira/browse/LANG-283
> Project: Commons Lang
> Issue Type: New Feature
> Affects Versions: 2.2
> Environment: Any
> Reporter: Aldrin Leal
> Priority: Trivial
> Fix For: 3.0
>
> Attachments: visitors.patch
>
>
> While doing commons-lang stuff, I found the repetitive nature of
> Builder stuff. Therefore, i decided to:
> a) Create a SingleBuilder (for ToString / HashCode) and a
> DualBuilder (CompareTo / Equals) interface, and make their classes
> implementing;
> b) Create a SingleBuilderVisitor and DualBuilderVisitor;
> c) Do the proper wiring, while creating new constructors using the visitors;
> d) Create new tests and ensuring javadoc plays nice along;
> There's a patch attached in this e-mail, done against the latest
> svn STABLE url for 2.2
> (http://svn.apache.org/repos/asf/jakarta/commons/proper/lang/branches/LANG_2_2_X/)
> There might be errors, but methinks it's a great idea to declare a
> constant like this in your source code.
> private static final EQUALS_VISITOR = new DualBuilderVisitor() {
> public void visit(DualBuilder builder, Object lhs, Object rhs) {
> Type lhsObj = (Type) lhs;
> Type rhsObj = (Type) rhs;
> builder.append(lhsObj.getId(),
> rhsObj.getId()).append(lhsObj.getName(), rhsObj.getName());
> }
> };
> And then, declare and instantiate builders like as, say:
> public boolean equals(Object anotherObj) {
> return new EqualsVisitor(EQUALS_VISITOR, this, anotherObj);
> }
> Please note this implementation, overrall, also lets you easily use
> a single visitor for either equals and compareto, thus creating a
> single point of management for all your
> field-maintenance-in-value-objects-needs.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (LANG-283) Visitors for Builders
Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-283?page=comments#action_12461426 ]
Stephen Colebourne commented on LANG-283:
-----------------------------------------
This looks very clever, but is probably beyond that which the builders were originally intended for.
> Visitors for Builders
> ---------------------
>
> Key: LANG-283
> URL: http://issues.apache.org/jira/browse/LANG-283
> Project: Commons Lang
> Issue Type: New Feature
> Affects Versions: 2.2
> Environment: Any
> Reporter: Aldrin Leal
> Priority: Trivial
> Fix For: 3.0
>
> Attachments: visitors.patch
>
>
> While doing commons-lang stuff, I found the repetitive nature of
> Builder stuff. Therefore, i decided to:
> a) Create a SingleBuilder (for ToString / HashCode) and a
> DualBuilder (CompareTo / Equals) interface, and make their classes
> implementing;
> b) Create a SingleBuilderVisitor and DualBuilderVisitor;
> c) Do the proper wiring, while creating new constructors using the visitors;
> d) Create new tests and ensuring javadoc plays nice along;
> There's a patch attached in this e-mail, done against the latest
> svn STABLE url for 2.2
> (http://svn.apache.org/repos/asf/jakarta/commons/proper/lang/branches/LANG_2_2_X/)
> There might be errors, but methinks it's a great idea to declare a
> constant like this in your source code.
> private static final EQUALS_VISITOR = new DualBuilderVisitor() {
> public void visit(DualBuilder builder, Object lhs, Object rhs) {
> Type lhsObj = (Type) lhs;
> Type rhsObj = (Type) rhs;
> builder.append(lhsObj.getId(),
> rhsObj.getId()).append(lhsObj.getName(), rhsObj.getName());
> }
> };
> And then, declare and instantiate builders like as, say:
> public boolean equals(Object anotherObj) {
> return new EqualsVisitor(EQUALS_VISITOR, this, anotherObj);
> }
> Please note this implementation, overrall, also lets you easily use
> a single visitor for either equals and compareto, thus creating a
> single point of management for all your
> field-maintenance-in-value-objects-needs.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org