org.apache.commons.collections.comparators
Class ComparableComparator
java.lang.Object
org.apache.commons.collections.comparators.ComparableComparator
- Comparator, Serializable
public class ComparableComparator
extends java.lang.Object
implements Comparator, Serializable
A Comparator that compares Comparable objects.
Throws ClassCastExceptions if the objects are not
Comparable, or if they are null.
Throws ClassCastException if the compareTo of both
objects do not provide an inverse result of each other
as per the Comparable javadoc. This Comparator is useful, for example,
for enforcing the natural order in custom implementations
of SortedSet and SortedMap.
$Id: ComparableComparator.java,v 1.5.2.1 2004/05/22 12:14:04 scolebourne Exp $- bayard@generationjava.com
ComparableComparator
public ComparableComparator()
compare
public int compare(Object o1,
Object o2)
getInstance
public static ComparableComparator getInstance()
Return a shared instance of a ComparableComparator. Developers are
encouraged to use the comparator returned from this method instead of
constructing a new instance to reduce allocation and GC overhead when
multiple comparable comparators may be used in the same VM.
Copyright © 2001-2004 Apache Software Foundation. Documenation generated ${TODAY}.