toolbox.dao
Class MapComparator
java.lang.Object
toolbox.dao.MapComparator
- All Implemented Interfaces:
- java.util.Comparator
public class MapComparator
- extends java.lang.Object
- implements java.util.Comparator
Comparator implementation to compare the values contained within Maps.
It can be used to sort Lists that store collections of Maps.
Constructor Summary |
MapComparator(java.lang.Object key,
java.lang.String order)
Construct a new instance. |
Method Summary |
int |
compare(java.lang.Object obj1,
java.lang.Object obj2)
Compare the values mapped to the specified key. |
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 |
MapComparator
public MapComparator(java.lang.Object key,
java.lang.String order)
- Construct a new instance.
- Parameters:
key
- Key that must be used to obtain values from the Maporder
- String indicating the sort order. Specify "asc" for
ascending order and "desc" for descending order.
compare
public int compare(java.lang.Object obj1,
java.lang.Object obj2)
- Compare the values mapped to the specified key.
- Specified by:
compare
in interface java.util.Comparator
- Parameters:
obj1
- First Mapobj2
- Second Map
- Returns:
- int indicating the result of the comparison.