Package org.jfree.data
Class KeyedValueComparator
java.lang.Object
org.jfree.data.KeyedValueComparator
- All Implemented Interfaces:
Serializable,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.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKeyedValueComparator(KeyedValueComparatorType type, SortOrder order) Creates a new comparator. -
Method Summary
Modifier and TypeMethodDescriptionintCompares twoKeyedValueinstances and returns anintthat indicates the relative order of the two objects.getOrder()Returns the sort order.getType()Returns the type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
KeyedValueComparator
Creates a new comparator.- Parameters:
type- the type (BY_KEYorBY_VALUE,nullnot permitted).order- the order (nullnot permitted).
-
-
Method Details
-
getType
Returns the type.- Returns:
- The type (never
null).
-
getOrder
Returns the sort order.- Returns:
- The sort order (never
null).
-
compare
Compares twoKeyedValueinstances and returns anintthat indicates the relative order of the two objects.- Specified by:
comparein interfaceComparator- Parameters:
o1- object 1.o2- object 2.- Returns:
- An int indicating the relative order of the objects.
-