org.jfree.data
Class KeyedValueComparator

java.lang.Object
  |
  +--org.jfree.data.KeyedValueComparator
All Implemented Interfaces:
java.util.Comparator

public class KeyedValueComparator
extends java.lang.Object
implements java.util.Comparator

A utility class that can compare and order two KeyedValue instances and sort them into ascending or descending order by key or by value.

Author:
David Gilbert

Constructor Summary
KeyedValueComparator(KeyedValueComparatorType type, SortOrder order)
          Creates a new comparator.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two KeyedValue instances and returns an int that indicates the relative order of the two objects.
 
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

KeyedValueComparator

public KeyedValueComparator(KeyedValueComparatorType type,
                            SortOrder order)
Creates a new comparator.

Parameters:
type - the type (BY_KEY or BY_VALUE).
order - the order (ascending or descending).
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two KeyedValue instances and returns an int that indicates the relative order of the two objects.

Specified by:
compare in interface java.util.Comparator
Parameters:
o1 - object 1.
o2 - object 2.
Returns:
An int indicating the relative order of the objects.