net.sf.molae.pipe.sorted
Class TransformedComparator<S,T>

java.lang.Object
  extended by net.sf.molae.pipe.sorted.TransformedComparator<S,T>
All Implemented Interfaces:
Comparator<T>

public final class TransformedComparator<S,T>
extends Object
implements Comparator<T>

Transforms both arguments with the underlying transformer and compares them.

Since:
2.0

Constructor Summary
TransformedComparator(Comparator<S> base, TwoWayTransformer<? super T,? extends S> transformer)
          Constructs a new TransformedComparator object.
 
Method Summary
 int compare(T o1, T o2)
          Transforms both arguments with the underlying transformer and compares them.
 boolean equals(Object obj)
          Compares the specified object with this comparator for equality.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformedComparator

public TransformedComparator(Comparator<S> base,
                             TwoWayTransformer<? super T,? extends S> transformer)
Constructs a new TransformedComparator object.

Parameters:
base - the underlying iterator. If null, the natural ordering of the elements will be used.
transformer - the underlying transformer
Throws:
NullPointerException - if the specified transformer is null.
Method Detail

compare

public int compare(T o1,
                   T o2)
Transforms both arguments with the underlying transformer and compares them.

Specified by:
compare in interface Comparator<T>
Throws:
ClassCastException - if o1 and o2 cannot be compared to one another using the comparator.
NullPointerException - if o1 or o2 is null and the comparator does not tolerate null elements.

equals

public boolean equals(Object obj)
Compares the specified object with this comparator for equality. Returns true, iff the parameter is a TransformedComparator and all properties are equal.

Specified by:
equals in interface Comparator<T>
Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if the specified Object is equal to this comparator