commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Attila Szegedi" <>
Subject Bean property comparator
Date Wed, 11 Feb 2004 13:43:36 GMT
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

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?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message