commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell" <flame...@gmail.com>
Subject Re: COMMONS-LANG-2.2 PATCH: Visitors for Builders [FAILED, PLEASE READ INTRO]
Date Sun, 08 Oct 2006 17:33:02 GMT
Hi Aldrin,

It definitely sounds interesting :)

The best way to get a patch in is to create a JIRA issue
(http://issues.apache.org/jira/browse/LANG) and attach the patch to
it.

Thanks,

Hen

On 10/8/06, Aldrin Leal <aldrinleal@gmail.com> wrote:
> Err, I tried to enclose the patch, however, ezmlm complained about the
> file size (abour 250KB). Any ideas? Well, I'm just resending the
> original message.
>
> =====
>
> Hello,
>
>    First of all, thanks for all your commons-good-work!
>
>    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.
>
>  Now, Thanks for reading this,
>
> --
> -- Aldrin Leal, aldrinleal@gmail.com
>
>
> --
> -- Aldrin Leal, aldrinleal@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message