Class TransformingComparator
- java.lang.Object
-
- org.apache.commons.collections.comparators.TransformingComparator
-
- All Implemented Interfaces:
java.util.Comparator
public class TransformingComparator extends java.lang.Object implements java.util.Comparator
Decorates another Comparator with transformation behavior. That is, the return value from the transform operation will be passed to the decoratedcompare
method.- Since:
- Commons Collections 2.0 (?)
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- See Also:
Transformer
,ComparableComparator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Comparator
decorated
The decorated comparator.protected Transformer
transformer
The transformer being used.
-
Constructor Summary
Constructors Constructor Description TransformingComparator(Transformer transformer)
Constructs an instance with the given Transformer and aComparableComparator
.TransformingComparator(Transformer transformer, java.util.Comparator decorated)
Constructs an instance with the given Transformer and Comparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(java.lang.Object obj1, java.lang.Object obj2)
Returns the result of comparing the values from the transform operation.
-
-
-
Field Detail
-
decorated
protected java.util.Comparator decorated
The decorated comparator.
-
transformer
protected Transformer transformer
The transformer being used.
-
-
Constructor Detail
-
TransformingComparator
public TransformingComparator(Transformer transformer)
Constructs an instance with the given Transformer and aComparableComparator
.- Parameters:
transformer
- what will transform the arguments tocompare
-
TransformingComparator
public TransformingComparator(Transformer transformer, java.util.Comparator decorated)
Constructs an instance with the given Transformer and Comparator.- Parameters:
transformer
- what will transform the arguments tocompare
decorated
- the decorated Comparator
-
-
Method Detail
-
compare
public int compare(java.lang.Object obj1, java.lang.Object obj2)
Returns the result of comparing the values from the transform operation.- Specified by:
compare
in interfacejava.util.Comparator
- 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
-
-