Class TransformingComparator
java.lang.Object
org.apache.commons.collections.comparators.TransformingComparator
- All Implemented Interfaces:
Comparator
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: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ComparatorThe decorated comparator.protected TransformerThe transformer being used. -
Constructor Summary
ConstructorsConstructorDescriptionTransformingComparator(Transformer transformer) Constructs an instance with the given Transformer and aComparableComparator.TransformingComparator(Transformer transformer, Comparator decorated) Constructs an instance with the given Transformer and Comparator. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
decorated
The decorated comparator. -
transformer
The transformer being used.
-
-
Constructor Details
-
TransformingComparator
Constructs an instance with the given Transformer and aComparableComparator.- Parameters:
transformer- what will transform the arguments tocompare
-
TransformingComparator
Constructs an instance with the given Transformer and Comparator.- Parameters:
transformer- what will transform the arguments tocomparedecorated- the decorated Comparator
-
-
Method Details
-
compare
Returns the result of comparing the values from the transform operation.- Specified by:
comparein interfaceComparator- 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
-