commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Yandell <bay...@generationjava.com>
Subject Re: Bean property comparator
Date Wed, 11 Feb 2004 16:04:46 GMT

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