Class RowGroupModel<T>

  • Type Parameters:
    T - the type of the row objects.
    All Implemented Interfaces:
    IRowGroupModel<T>, IPersistable

    public class RowGroupModel<T>
    extends Object
    implements IRowGroupModel<T>
    A thread-safe implementation of IRowGroupModel which is optimised for larger data-sets (it should cope with at least 10k rows spread across 2-300 groups).
    Author:
    Stefan Bolton
    • Constructor Detail

      • RowGroupModel

        public RowGroupModel()
    • Method Detail

      • getRowFromIndexCache

        public T getRowFromIndexCache​(int rowIndex)
        Description copied from interface: IRowGroupModel
        Retrieves a row T by it's index from our cache. It will be added to the cache if not present.
        Specified by:
        getRowFromIndexCache in interface IRowGroupModel<T>
      • getIndexFromRowCache

        public int getIndexFromRowCache​(T row)
        Description copied from interface: IRowGroupModel
        Retrieves a row's index by from our cache. It will be added to the cache if not present.
        Specified by:
        getIndexFromRowCache in interface IRowGroupModel<T>
      • setSuppressNoficiations

        public void setSuppressNoficiations​(boolean suppressNoficiations)
        Set to true to stop model change notifications.
        Parameters:
        suppressNoficiations -
      • isSuppressNoficiations

        public boolean isSuppressNoficiations()
      • addRowGroups

        public void addRowGroups​(List<IRowGroup<T>> rowGroups)
        Description copied from interface: IRowGroupModel

        Adds multiple row groups into the model and only fires off a single change notification.

        Specified by:
        addRowGroups in interface IRowGroupModel<T>
        Parameters:
        rowGroups - A list of IRowGroups to add.
      • addRowGroup

        public boolean addRowGroup​(IRowGroup<T> rowGroup)
        Description copied from interface: IRowGroupModel

        Adds a group into the model.

        A notification should be sent to any IRowGroupModelListeners to indicate a change in the model has occurred.

        Specified by:
        addRowGroup in interface IRowGroupModel<T>
        Parameters:
        rowGroup - The IRowGroup to be added.
        Returns:
        false if the group wasn't added.
      • removeRowGroup

        public boolean removeRowGroup​(IRowGroup<T> rowGroup)
        Description copied from interface: IRowGroupModel

        Removes the group from the model.

        A notification should be sent to any IRowGroupModelListeners to indicate a change in the model has occurred.

        Specified by:
        removeRowGroup in interface IRowGroupModel<T>
        Parameters:
        rowGroup - The IRowGroup to remove.
        Returns:
        true if the group was present and removed, false if the group was not present.
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface IRowGroupModel<T>
        Returns:
        true if there are no IRowGroups in the model. Note: if there are groups but there are no rows, then true is still returned.
      • saveState

        public void saveState​(String prefix,
                              Properties properties)
        Description copied from interface: IPersistable
        Saves the state to the given Properties using the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.
        Specified by:
        saveState in interface IPersistable
        Parameters:
        prefix - The prefix to use for the state keys. Is also used as the state configuration name.
        properties - The Properties instance to save the state to.
      • loadState

        public void loadState​(String prefix,
                              Properties properties)
        Description copied from interface: IPersistable
        Restore the state out of the given Properties identified by the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.
        Specified by:
        loadState in interface IPersistable
        Parameters:
        prefix - The prefix to use for the state keys. Is also used as the state configuration name.
        properties - The Properties instance to load the state from.