public class TransformingComparator<E> extends Object implements Comparator<E>, Serializable
compare method.
This class is Serializable from Commons Collections 4.0.
Transformer,
ComparableComparator,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected Comparator<E> |
decorated
The decorated comparator.
|
protected Transformer<? super E,? extends E> |
transformer
The transformer being used.
|
| Constructor and Description |
|---|
TransformingComparator(Transformer<? super E,? extends E> transformer)
Constructs an instance with the given Transformer and a
ComparableComparator. |
TransformingComparator(Transformer<? super E,? extends E> transformer,
Comparator<E> decorated)
Constructs an instance with the given Transformer and Comparator.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(E obj1,
E obj2)
Returns the result of comparing the values from the transform operation.
|
boolean |
equals(Object object)
Returns
true iff that Object is
is a Comparator whose ordering is known to be
equivalent to mine. |
int |
hashCode()
Implement a hash code for this comparator that is consistent with
equals. |
protected final Comparator<E> decorated
protected final Transformer<? super E,? extends E> transformer
public TransformingComparator(Transformer<? super E,? extends E> transformer)
ComparableComparator.transformer - what will transform the arguments to comparepublic TransformingComparator(Transformer<? super E,? extends E> transformer, Comparator<E> decorated)
transformer - what will transform the arguments to comparedecorated - the decorated Comparatorpublic int compare(E obj1, E obj2)
compare in interface Comparator<E>obj1 - the first object to transform then compareobj2 - the second object to transform then comparepublic int hashCode()
equals.public boolean equals(Object object)
true iff that Object is
is a Comparator whose ordering is known to be
equivalent to mine.
This implementation returns true
iff that is a TransformingComparator
whose attributes are equal to mine.
equals in interface Comparator<E>equals in class Objectobject - the object to compare toCopyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.