Package org.jfree.data
Class KeyedValueComparator
- java.lang.Object
-
- org.jfree.data.KeyedValueComparator
-
- All Implemented Interfaces:
Serializable
,Comparator
public class KeyedValueComparator extends Object implements Comparator, Serializable
A utility class that can compare and order twoKeyedValue
instances and sort them into ascending or descending order by key or by value.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description KeyedValueComparator(KeyedValueComparatorType type, org.jfree.util.SortOrder order)
Creates a new comparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(Object o1, Object o2)
Compares twoKeyedValue
instances and returns anint
that indicates the relative order of the two objects.org.jfree.util.SortOrder
getOrder()
Returns the sort order.KeyedValueComparatorType
getType()
Returns the type.-
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, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
KeyedValueComparator
public KeyedValueComparator(KeyedValueComparatorType type, org.jfree.util.SortOrder order)
Creates a new comparator.- Parameters:
type
- the type (BY_KEY
orBY_VALUE
,null
not permitted).order
- the order (null
not permitted).
-
-
Method Detail
-
getType
public KeyedValueComparatorType getType()
Returns the type.- Returns:
- The type (never
null
).
-
getOrder
public org.jfree.util.SortOrder getOrder()
Returns the sort order.- Returns:
- The sort order (never
null
).
-
compare
public int compare(Object o1, Object o2)
Compares twoKeyedValue
instances and returns anint
that indicates the relative order of the two objects.- Specified by:
compare
in interfaceComparator
- Parameters:
o1
- object 1.o2
- object 2.- Returns:
- An int indicating the relative order of the objects.
-
-