You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2009/10/24 14:28:40 UTC

Re: svn commit: r775045 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/builder/ test/org/apache/commons/lang/builder/

bayard@apache.org wrote:
> URL: http://svn.apache.org/viewvc?rev=775045&view=rev
> Log:
> Genericizing per LANG-336. Removed two lines in the test that were trying to build a to string up to a class that was not in the hierarchy. The compiler now protects against this. 
 >
> -public class ReflectionToStringBuilder extends ToStringBuilder {
> +public class ReflectionToStringBuilder<T> extends ToStringBuilder<T> {
 >
> -public class ToStringBuilder {
> +public class ToStringBuilder<T> {
>  

I think these gnerics are unecessary and provide insufficient benefit.

The use case for ToStringBuilder is a quick and easy way to produce a 
toString. Users shouldn't have to manually specify the class that they 
are building the toString for. Compare today vs generics:

new ToStringBuilder()
   .append(.......)
   .toString();

new ToStringBuilder<Person>()
   .append(.......)
   .toString();

The issue of blocking the input specifying an invalid super class can be 
  handled by method level generics on the static factory and 
constructor, plus a safety runtime check in setUpToClass().

Stephen


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


Re: svn commit: r775045 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/builder/ test/org/apache/commons/lang/builder/

Posted by sebb <se...@gmail.com>.
On 24/10/2009, Stephen Colebourne <sc...@btopenworld.com> wrote:
> bayard@apache.org wrote:
>
> > URL: http://svn.apache.org/viewvc?rev=775045&view=rev
> > Log:
> > Genericizing per LANG-336. Removed two lines in the test that were trying
> to build a to string up to a class that was not in the hierarchy. The
> compiler now protects against this.
> >
>  >
>
> > -public class ReflectionToStringBuilder extends ToStringBuilder {
> > +public class ReflectionToStringBuilder<T> extends ToStringBuilder<T> {
> >
>  >
>
> > -public class ToStringBuilder {
> > +public class ToStringBuilder<T> {
> >
> >
>
>  I think these gnerics are unecessary and provide insufficient benefit.

I'm inclined to agree.

The same applies even more to StrLookup, whose Javadoc says:

"Lookup a String key to a String value."

Why does that need generification?

>  The use case for ToStringBuilder is a quick and easy way to produce a
> toString. Users shouldn't have to manually specify the class that they are
> building the toString for. Compare today vs generics:
>
>  new ToStringBuilder()
>   .append(.......)
>   .toString();
>
>  new ToStringBuilder<Person>()
>   .append(.......)
>   .toString();
>
>  The issue of blocking the input specifying an invalid super class can be
> handled by method level generics on the static factory and constructor, plus
> a safety runtime check in setUpToClass().
>
>  Stephen
>
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

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