Class GroupByComparator<T>

    • Field Detail

      • summaryColumnCache

        protected Map<Integer,​Boolean> summaryColumnCache
        Cache that is used to increase the performance on sorting. The information whether a column is a summary column is only retrieved once and not calculated everytime.
      • groupByObjectComparatorCache

        protected Map<GroupByObject,​org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByComparator.GroupByObjectValueCache> groupByObjectComparatorCache
        Cache that is used to increase the performance on sorting by summary values. Necessary because the summary value is not carried by the GroupByObject but retrieved from the GroupByDataLayer. Since the retrieval is done via row index rather than the GroupByObject, the row index needs to be calculated in order to get the correct values. This is done via List.indexOf(Object) which is quite time consuming. So this cache is used to reduce the amount of indexOf calls drastically.

        As this cache is only used to increase the performance on sorting, the life time of this cache is reduced to a sort operation. It therefore gets cleared on every structural change.

    • Constructor Detail

      • GroupByComparator

        public GroupByComparator​(GroupByModel groupByModel,
                                 IColumnAccessor<T> columnAccessor)
        Parameters:
        groupByModel - The GroupByModel necessary to retrieve information about the current groupBy state.
        columnAccessor - The IColumnAccessor necessary to retrieve the column values of elements.
      • GroupByComparator

        public GroupByComparator​(GroupByModel groupByModel,
                                 IColumnAccessor<T> columnAccessor,
                                 GroupByDataLayer<T> dataLayer)
        Parameters:
        groupByModel - The GroupByModel necessary to retrieve information about the current groupBy state.
        columnAccessor - The IColumnAccessor necessary to retrieve the column values of elements.
        dataLayer - The GroupByDataLayer that should be used to retrieve groupBy summary values for sorting the tree structure. Can be null to avoid retrieving and inspecting summary values on sorting.
    • Method Detail

      • isTreeColumn

        protected boolean isTreeColumn​(int columnIndex)
        Parameters:
        columnIndex - The column index of the column that should be checked.
        Returns:
        true if the column at the given index is the tree column, false if not or if no treeLayer reference is set to this GroupByComparator
      • getSortModel

        public ISortModel getSortModel()
        Specified by:
        getSortModel in interface IGroupByComparator<T>
        Returns:
        The ISortModel that is used to retrieve the column value comparators and the sort direction in case a groupBy value is sorted which will directly affect the tree structure build. Can be null which leads to a static tree structure that only allows sorting for leafs within groups.
      • setSortModel

        public void setSortModel​(ISortModel sortModel)
        Specified by:
        setSortModel in interface IGroupByComparator<T>
        Parameters:
        sortModel - The ISortModel that is used to retrieve the column value comparators and the sort direction in case a groupBy value is sorted which will directly affect the tree structure build. Can be null which leads to a static tree structure that only allows sorting for leafs within groups.
      • setTreeLayer

        public void setTreeLayer​(IUniqueIndexLayer treeLayer)
        Specified by:
        setTreeLayer in interface IGroupByComparator<T>
        Parameters:
        treeLayer - The IUniqueIndexLayer that should be used to retrieve config labels for a column. Needed to be able to determine if the column which is used for sorting is the tree column. Can be null which avoids specialized handling of tree / non tree columns.
      • setDataLayer

        public void setDataLayer​(GroupByDataLayer<T> dataLayer)
        Specified by:
        setDataLayer in interface IGroupByComparator<T>
        Parameters:
        dataLayer - The GroupByDataLayer that should be used to retrieve groupBy summary values for sorting the tree structure. Can be null to avoid retrieving and inspecting summary values on sorting.
      • isSummaryColumn

        protected Boolean isSummaryColumn​(GroupByObject groupBy,
                                          int columnIndex)
        Parameters:
        groupBy - The GroupByObject for which the cache information is requested. Needed to retrieve the information if it is not yet cached.
        columnIndex - The column for which the cache information is requested.
        Returns:
        true if the given column is a summary column, false if not
      • getSummaryValueFromCache

        protected Object getSummaryValueFromCache​(GroupByObject groupBy,
                                                  int columnIndex)
        Returns the cached summary value for the given GroupByObject and column index. If there is no cache information yet, it will be build.
        Parameters:
        groupBy - The GroupByObject for which the cache information is requested.
        columnIndex - The column for which the cache information is requested.
        Returns:
        The summary value for the given GroupByObject and column index or null in case there is no GroupByDataLayer configured in for this GroupByComparator.