## org.apache.commons.collections.comparators
Class TransformingComparator

    java.lang.Object
      org.apache.commons.collections.comparators.TransformingComparator

All Implemented Interfaces:
  Comparator

public class TransformingComparator
extends Object
implements 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$ $Date$
See Also:
  `Transformer`, `ComparableComparator`

Field Summary
`protected Comparator` `decorated` The decorated comparator.
`protected Transformer` `transformer` The transformer being used.

Constructor Summary
`TransformingComparator(Transformer transformer)` Constructs an instance with the given Transformer and a `ComparableComparator`.
`TransformingComparator(Transformer transformer, Comparator decorated)` Constructs an instance with the given Transformer and Comparator.

Method Summary
`int` `compare(Object obj1, Object 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`

Methods inherited from interface java.util.Comparator
`equals`

Field Detail

### decorated

    protected 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 a `ComparableComparator`.

Parameters:
  `transformer` - what will transform the arguments to `compare`

### TransformingComparator

    public TransformingComparator(Transformer transformer,
                                  Comparator decorated)

  Constructs an instance with the given Transformer and Comparator.

Parameters:
  `transformer` - what will transform the arguments to `compare`
  `decorated` - the decorated Comparator

Method Detail

### compare

    public int compare(Object obj1,
                       Object obj2)

  Returns the result of comparing the values from the transform operation.

  Specified by:
    `compare` in interface `Comparator`
  Parameters:
    `obj1` - the first object to transform then compare
    `obj2` - the second object to transform then compare
  Returns:
    negative if obj1 is less, positive if greater, zero if equal

Copyright © 2001-2005 Apache Software Foundation. All Rights Reserved.