Class CollectionWithPagingInfo<T>

  • All Implemented Interfaces:
    SerializablePagedCollection

    public class CollectionWithPagingInfo<T>
    extends Object
    implements SerializablePagedCollection
    A wrapper around Collection that supports paging information. CollectionWithPagingInfo is immutable and collections are unmodifiable. Use the asPaged methods to construct it. collection - The collection hasMoreItems - Indicates the total number of items available. Can be greater than the number of items returned in the list. totalItems - Indicates the total number of items available. Can be greater than the number of items returned in the list.
    Author:
    Gethin James.
    • Constructor Detail

      • CollectionWithPagingInfo

        protected CollectionWithPagingInfo​(Collection<T> collection,
                                           Paging paging,
                                           boolean hasMoreItems,
                                           Integer totalItems,
                                           Object sourceEntity,
                                           SearchContext context)
        Constructs a new CollectionWithPagingInfo.
        Parameters:
        collection - - the collection that needs to be paged.
        paging - - Paging request info
        hasMoreItems - - Are there more items after this Collection?
        totalItems - - The total number of items available.
    • Method Detail

      • asPaged

        public static <T> CollectionWithPagingInfo<T> asPaged​(Paging paging,
                                                              Collection<T> aCollection)
        Constructs a new CollectionWithPagingInfo. It automatically sets the total items based on the collection size and sets the hasMoreItems variable to false.
        Parameters:
        paging - - Paging request info
        aCollection - - the collection that needs to be paged.
        Returns:
        CollectionWithPagingInfo
      • asPagedCollection

        public static <T> CollectionWithPagingInfo<T> asPagedCollection​(T... entity)
        Constructs a new CollectionWithPagingInfo using a number of entity values. It automatically creates a Collection, sets the total items and sets the hasMoreItems variable to false. Paging is set to the default values.
        Parameters:
        entity - - the entities to turn into a collection
        Returns:
        CollectionWithPagingInfo
      • asPaged

        public static <T> CollectionWithPagingInfo<T> asPaged​(Paging paging,
                                                              Collection<T> aCollection,
                                                              boolean hasMoreItems,
                                                              Integer totalItems)
        Constructs a new CollectionWithPagingInfo.
        Parameters:
        paging - - Paging request info
        aCollection - - the collection that needs to be paged.
        hasMoreItems - - Are there more items after this Collection?
        totalItems - - The total number of items available.
        Returns:
        CollectionWithPagingInfo
      • asPaged

        public static <T> CollectionWithPagingInfo<T> asPaged​(Paging paging,
                                                              Collection<T> aCollection,
                                                              boolean hasMoreItems,
                                                              Integer totalItems,
                                                              Object sourceEntity)
        Constructs a new CollectionWithPagingInfo. Not for public use.
        Parameters:
        paging - - Paging request info
        aCollection - - the collection that needs to be paged.
        hasMoreItems - - Are there more items after this Collection?
        totalItems - - The total number of items available.
        sourceEntity - - The parent/source entity responsible for the collection
        Returns:
        CollectionWithPagingInfo
      • asPaged

        public static <T> CollectionWithPagingInfo<T> asPaged​(Paging paging,
                                                              Collection<T> aCollection,
                                                              boolean hasMoreItems,
                                                              Integer totalItems,
                                                              Object sourceEntity,
                                                              SearchContext context)
        Constructs a new CollectionWithPagingInfo. Not for public use.
        Parameters:
        paging - - Paging request info
        aCollection - - the collection that needs to be paged.
        hasMoreItems - - Are there more items after this Collection?
        totalItems - - The total number of items available.
        sourceEntity - - The parent/source entity responsible for the collection
        context - - The search context
        Returns:
        CollectionWithPagingInfo
      • hasMoreItems

        public boolean hasMoreItems()
        Indicates if the returned collection has more items after the current returned list.
        Specified by:
        hasMoreItems in interface SerializablePagedCollection<T>