Package xal.tools.data
Class KeyValueSorting
java.lang.Object
xal.tools.data.KeyValueSorting
factory to support sorting using the key value adaptor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intindicates ascending orderstatic final intindicates ascending order -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Comparator<T>comparatorForKeyPath(String keyPath, int order) Generate a comparator that compares records according to the method obtained by a key value adaptor generated internally.static <T> Comparator<T>comparatorForKeyPath(KeyValueAdaptor adaptor, String keyPath, int order) Generate a comparator that compares records according to the method obtained by the key value adaptor The keyed values being compared are assumed to be comparable.static <T> Comparator<T>compoundComparator(Comparator<T>... comparators) Coalesce the specified comparators to generate a compound comparator whose sub comparators are evaluated in the specified order.
-
Field Details
-
DESCENDING
public static final int DESCENDINGindicates ascending order- See Also:
-
ASCENDING
public static final int ASCENDINGindicates ascending order- See Also:
-
-
Method Details
-
comparatorForKeyPath
Generate a comparator that compares records according to the method obtained by a key value adaptor generated internally. The keyed values being compared are assumed to be comparable.- Parameters:
keyPath- indicates the method used for comparisonorder- either ASCENDING or DESCENDING- Returns:
- a comparator which compares objects according to the keyed parameter
-
comparatorForKeyPath
public static <T> Comparator<T> comparatorForKeyPath(KeyValueAdaptor adaptor, String keyPath, int order) Generate a comparator that compares records according to the method obtained by the key value adaptor The keyed values being compared are assumed to be comparable.- Parameters:
adaptor- key value adaptor used for getting the method associated with the keykeyPath- indicates the method used for comparisonorder- either ASCENDING or DESCENDING- Returns:
- a comparator which compares objects according to the keyed parameter
-
compoundComparator
Coalesce the specified comparators to generate a compound comparator whose sub comparators are evaluated in the specified order.- Parameters:
comparators- array of parameters to coalesce taken in order (sort first by the first comparator and last by the last comparator)- Returns:
- the compound comparator
-