I have attached a very simple, but powerful TransformingComparator that I wrote. It would go well in the Collections framework. It decorates another Comparator with behavior from any Transformer. That is, the return value from the #transform method will be passed to the #compare method on the decorated Comparator. The default decorated Comparator is the ComparableComparator.
This will allow you to reuse Transformers and Comparators in interesting and powerful combinations, like use an existing Address comparator to sort a list of Employees by address (for example). I also have a generic ReflectingTransformer that I wrote, which, when coupled with the attached TransformingComparator will allow you to dynamically sort a collection based on any getter. However, it uses a generic ReflectionHelper that wouldn't fit within the Collections framework (I don't know where it would go). But if anyone is interested in that code too, I'd be happy to share it. Jonathan ===== Jonathan Carlson [EMAIL PROTECTED] Minneapolis, Minnesota __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
TransformingComparator.java
Description: TransformingComparator.java
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
