commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Attila Szegedi" <szege...@freemail.hu>
Subject Re: Bean property comparator
Date Wed, 11 Feb 2004 16:40:13 GMT
Hm, you're right. Oversight on my part. Anyway, I think I'll keep using my
own comparator, as the one now existing in Commons relies on
PropertyUtils.getProperty(), and it's implementation has a bit too high
overhead for my taste - all those indexOf(), substring() and instanceof
calls when all I want is invoke a single method reflectively (that got
cached at the comparator construction time). I believe it can significantly
impact execution time when sorting large lists...

Anyway, thanks for the pointer.

Attila.

"Henri Yandell" <bayard@generationjava.com> wrote in message
news:Pine.LNX.4.44.0402111103330.25708-100000@umbongo.flamefew.net...
>
> It's a part of BeanUtils, org.apache.commons.beanutils.BeanComparator I
> think.
>
> It doesn't take the class in the constructor, so will work on any class
> with getBirthDate().
>
> Hen
>
> On Wed, 11 Feb 2004, Attila Szegedi wrote:
>
> > Hi folks,
> >
> > there's one comparator I've been missing from the commons-collection: a
> > comparator that uses a specified bean property of objects to perform the
> > comparisons.
> >
> > Basically, it works like this: if you construct an instance with:
> >
> > Comparator c =
> >   new BeanPropertyComparator(Customer.class, "birthDate");
> >
> > c will use the natural ordering on the values of Customer.getBirthDate()
to
> > compare Customer objects.
> >
> > There's an alternative constructor to specify an embedded comparator for
> > comparing the retrieved property values:
> >
> > Comparator c =
> >     new BeanPropertyComparator(
> >        Customer.class, "birthDate", new ReverseComparator());
> >
> > Admittedly, the class is fairly trivial, but I already have it
implemented
> > and tested - would the project be interested in the contribution?
> >
> > Attila.
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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