Class CollectionWithPagingInfo<T>

  • All Implemented Interfaces:
    SerializablePagedCollection

    public class CollectionWithPagingInfo<T>
    extends java.lang.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 Summary

      Constructors 
      Modifier Constructor Description
      protected CollectionWithPagingInfo​(java.util.Collection<T> collection, Paging paging, boolean hasMoreItems, java.lang.Integer totalItems, java.lang.Object sourceEntity, SearchContext context)
      Constructs a new CollectionWithPagingInfo.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> CollectionWithPagingInfo<T> asPaged​(Paging paging, java.util.Collection<T> aCollection)
      Constructs a new CollectionWithPagingInfo.
      static <T> CollectionWithPagingInfo<T> asPaged​(Paging paging, java.util.Collection<T> aCollection, boolean hasMoreItems, java.lang.Integer totalItems)
      Constructs a new CollectionWithPagingInfo.
      static <T> CollectionWithPagingInfo<T> asPaged​(Paging paging, java.util.Collection<T> aCollection, boolean hasMoreItems, java.lang.Integer totalItems, java.lang.Object sourceEntity)
      Constructs a new CollectionWithPagingInfo.
      static <T> CollectionWithPagingInfo<T> asPaged​(Paging paging, java.util.Collection<T> aCollection, boolean hasMoreItems, java.lang.Integer totalItems, java.lang.Object sourceEntity, SearchContext context)
      Constructs a new CollectionWithPagingInfo.
      static <T> CollectionWithPagingInfo<T> asPagedCollection​(T... entity)
      Constructs a new CollectionWithPagingInfo using a number of entity values.
      java.util.Collection<T> getCollection()
      Returns the Collection object
      SearchContext getContext()
      The search context for the collection
      Paging getPaging()
      The requested paging parameters set by the client
      java.lang.Object getSourceEntity()
      The parent/source entity responsible for the collection
      java.lang.Integer getTotalItems()
      Indicates the total number of items available.
      boolean hasMoreItems()
      Indicates if the returned collection has more items after the current returned list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CollectionWithPagingInfo

        protected CollectionWithPagingInfo​(java.util.Collection<T> collection,
                                           Paging paging,
                                           boolean hasMoreItems,
                                           java.lang.Integer totalItems,
                                           java.lang.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,
                                                              java.util.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,
                                                              java.util.Collection<T> aCollection,
                                                              boolean hasMoreItems,
                                                              java.lang.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,
                                                              java.util.Collection<T> aCollection,
                                                              boolean hasMoreItems,
                                                              java.lang.Integer totalItems,
                                                              java.lang.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,
                                                              java.util.Collection<T> aCollection,
                                                              boolean hasMoreItems,
                                                              java.lang.Integer totalItems,
                                                              java.lang.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>
      • getTotalItems

        public java.lang.Integer getTotalItems()
        Indicates the total number of items available. Can be greater than the number of items returned in the list.
        Specified by:
        getTotalItems in interface SerializablePagedCollection<T>