org.apache.commons.collections.comparators
Class TransformingComparator<I,O>
java.lang.Object
org.apache.commons.collections.comparators.TransformingComparator<I,O>
- All Implemented Interfaces:
- Comparator<I>
public class TransformingComparator<I,O>
- extends Object
- implements Comparator<I>
Decorates another Comparator with transformation behavior. That is, the
return value from the transform operation will be passed to the decorated
compare method.
- Since:
- Commons Collections 2.0 (?)
- Version:
- $Revision: 1.1.1.1 $ $Date: 2005/05/23 04:34:11 $
- See Also:
Transformer,
ComparableComparator
|
Method Summary |
int |
compare(I obj1,
I obj2)
Returns the result of comparing the values from the transform operation. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
decorated
protected Comparator<O> decorated
- The decorated comparator.
transformer
protected Transformer<I,O> transformer
- The transformer being used.
TransformingComparator
public TransformingComparator(Transformer<I,O> transformer,
Comparator<O> decorated)
- Constructs an instance with the given Transformer and Comparator.
- Parameters:
transformer - what will transform the arguments to comparedecorated - the decorated Comparator
compare
public int compare(I obj1,
I obj2)
- Returns the result of comparing the values from the transform operation.
- Specified by:
compare in interface Comparator<I>
- Parameters:
obj1 - the first object to transform then compareobj2 - the second object to transform then compare
- Returns:
- negative if obj1 is less, positive if greater, zero if equal
Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.