net.sf.jagg
Class ComparableComparator<T extends java.lang.Comparable<? super T>>

java.lang.Object
  extended by net.sf.jagg.ComparableComparator<T>
All Implemented Interfaces:
java.util.Comparator<T>

public class ComparableComparator<T extends java.lang.Comparable<? super T>>
extends java.lang.Object
implements java.util.Comparator<T>

This adapter class compares Comparables. It compares its objects exactly like T's compareTo method (which exists because T is Comparable).

Since:
0.1.0
Author:
Randy Gettman

Constructor Summary
ComparableComparator()
           
 
Method Summary
 int compare(T o1, T o2)
          Compares the given objects to determine order.
 
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
 

Constructor Detail

ComparableComparator

public ComparableComparator()
Method Detail

compare

public int compare(T o1,
                   T o2)

Compares the given objects to determine order. Fulfills the Comparator contract by returning a negative integer, 0, or a positive integer if o1 is less than, equal to, or greater than o2.

Nulls compare equal to each other, and a null compares greater than non-nulls.

Specified by:
compare in interface java.util.Comparator<T extends java.lang.Comparable<? super T>>
Parameters:
o1 - The left-hand-side object to compare.
o2 - The right-hand-side object to compare.
Returns:
A negative integer, 0, or a positive integer if o1 is less than, equal to, or greater than o2.


Copyright © 2010-2013 jAgg Team. All Rights Reserved.