Package org.jfree.data
Class KeyedValueComparator
- java.lang.Object
-
- org.jfree.data.KeyedValueComparator
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Comparator
public class KeyedValueComparator extends java.lang.Object implements java.util.Comparator, java.io.SerializableA utility class that can compare and order twoKeyedValueinstances and sort them into ascending or descending order by key or by value.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private SortOrderorderThe sort order.private KeyedValueComparatorTypetypeThe comparator type.
-
Constructor Summary
Constructors Constructor Description KeyedValueComparator(KeyedValueComparatorType type, SortOrder order)Creates a new comparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(java.lang.Object o1, java.lang.Object o2)Compares twoKeyedValueinstances and returns anintthat indicates the relative order of the two objects.SortOrdergetOrder()Returns the sort order.KeyedValueComparatorTypegetType()Returns the type.
-
-
-
Field Detail
-
type
private KeyedValueComparatorType type
The comparator type.
-
order
private SortOrder order
The sort order.
-
-
Constructor Detail
-
KeyedValueComparator
public KeyedValueComparator(KeyedValueComparatorType type, SortOrder order)
Creates a new comparator.- Parameters:
type- the type (BY_KEYorBY_VALUE,nullnot permitted).order- the order (nullnot permitted).
-
-
Method Detail
-
getType
public KeyedValueComparatorType getType()
Returns the type.- Returns:
- The type (never
null).
-
getOrder
public SortOrder getOrder()
Returns the sort order.- Returns:
- The sort order (never
null).
-
compare
public int compare(java.lang.Object o1, java.lang.Object o2)Compares twoKeyedValueinstances and returns anintthat indicates the relative order of the two objects.- Specified by:
comparein interfacejava.util.Comparator- Parameters:
o1- object 1.o2- object 2.- Returns:
- An int indicating the relative order of the objects.
-
-