Class MultiColumnComparator

java.lang.Object
org.kuali.rice.krad.uif.util.MultiColumnComparator
All Implemented Interfaces:
Comparator<Integer>

public class MultiColumnComparator extends Object implements Comparator<Integer>
Comparator used for server side sorting of CollectionGroup data.

This may include DataFields, as well as Fields that don't map directly to elements in the model collection, such as LinkFields that may contain expressions.

NOTE: This class is not thread safe, and each instance is intended to be used only once.

Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Constructor Details

    • MultiColumnComparator

      public MultiColumnComparator(List<Object> modelCollection, CollectionGroup collectionGroup, List<ColumnSort> columnSorts, ViewModel form, View view)
      Constructs a MultiColumnComparator instance
      Parameters:
      modelCollection - the model collection that the CollectionGroup is associated with
      collectionGroup - the CollectionGroup whose columns are being sorted
      columnSorts - A list from highest to lowest precedence of the column sorts to apply
      form - object containing the view's data
      view - The view
  • Method Details

    • compare

      public int compare(Integer index1, Integer index2)
      Compares the modelCollecton element at index1 to the element at index2 based on the provided ColumnSorts.
      Specified by:
      compare in interface Comparator<Integer>
      Parameters:
      index1 - the index of the first modelCollection element used for comparison
      index2 - the index of the second modelCollection element used for comparison
      Returns:
      0 if the two elements are considered equal, a positive integer if the element at index1 is considered greater, else a negative integer
    • buildPrototypeRow

      protected List<Field> buildPrototypeRow()
      Build a List of prototype Fields representing a row of the table.

      Any DataFields will have their binding paths shortened to access the model collection elements directly, instead of via the data object

      Returns:
      a List of prototype Fields representing a row in the table