Class KeyValueSorting

java.lang.Object
xal.tools.data.KeyValueSorting

public class KeyValueSorting extends Object
factory to support sorting using the key value adaptor
  • Field Details

    • DESCENDING

      public static final int DESCENDING
      indicates ascending order
      See Also:
    • ASCENDING

      public static final int ASCENDING
      indicates ascending order
      See Also:
  • Method Details

    • comparatorForKeyPath

      public static <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. The keyed values being compared are assumed to be comparable.
      Parameters:
      keyPath - indicates the method used for comparison
      order - 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 key
      keyPath - indicates the method used for comparison
      order - either ASCENDING or DESCENDING
      Returns:
      a comparator which compares objects according to the keyed parameter
    • compoundComparator

      @SafeVarargs public 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.
      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