Jan 27, 2012

Java Comparators

BeanComparator

Collections.sort(catalogs, new BeanComparator("publishCatalogName"));
Note: you should check if the performance hit is worth it, since it uses reflection, you might be taking a hit.

ComparatorChain

comparaterChain.addComparator( new ReverseComparator
(new BeanComparator("age") );
Allows you to chain existing comparators together.

Similar comparators from apache

No comments:

Post a Comment