Class CollectionWithPagingInfo<T>

java.lang.Object
org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo<T>
All Implemented Interfaces:
SerializablePagedCollection<T>

public class CollectionWithPagingInfo<T> extends Object implements SerializablePagedCollection<T>
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 Details

    • 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 Details

    • from

      public static <T> CollectionWithPagingInfo<T> from(SerializablePagedCollection<T> pagedCollection)
      Constructs a new CollectionWithPagingInfo from a SerializablePagedCollection instance.
      Parameters:
      pagedCollection - - a collection with paging information
      Returns:
      CollectionWithPagingInfo
    • 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
    • getCollection

      public Collection<T> getCollection()
      Returns the Collection object
      Specified by:
      getCollection in interface SerializablePagedCollection<T>
      Returns:
      Collection
    • 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 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>
    • getSourceEntity

      public Object getSourceEntity()
      The parent/source entity responsible for the collection
      Specified by:
      getSourceEntity in interface SerializablePagedCollection<T>
    • getPaging

      public Paging getPaging()
      The requested paging parameters set by the client
      Specified by:
      getPaging in interface SerializablePagedCollection<T>
    • getContext

      public SearchContext getContext()
      Description copied from interface: SerializablePagedCollection
      The search context for the collection
      Specified by:
      getContext in interface SerializablePagedCollection<T>