Class CollectionWithPagingInfo<T>
- java.lang.Object
-
- org.alfresco.rest.framework.resource.parameters.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 Summary
Constructors Modifier Constructor Description protectedCollectionWithPagingInfo(Collection<T> collection, Paging paging, boolean hasMoreItems, Integer totalItems, 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, Collection<T> aCollection)Constructs a new CollectionWithPagingInfo.static <T> CollectionWithPagingInfo<T>asPaged(Paging paging, Collection<T> aCollection, boolean hasMoreItems, Integer totalItems)Constructs a new CollectionWithPagingInfo.static <T> CollectionWithPagingInfo<T>asPaged(Paging paging, Collection<T> aCollection, boolean hasMoreItems, Integer totalItems, Object sourceEntity)Constructs a new CollectionWithPagingInfo.static <T> CollectionWithPagingInfo<T>asPaged(Paging paging, Collection<T> aCollection, boolean hasMoreItems, Integer totalItems, 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.Collection<T>getCollection()Returns the Collection objectSearchContextgetContext()The search context for the collectionPaginggetPaging()The requested paging parameters set by the clientObjectgetSourceEntity()The parent/source entity responsible for the collectionIntegergetTotalItems()Indicates the total number of items available.booleanhasMoreItems()Indicates if the returned collection has more items after the current returned list.
-
-
-
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 infohasMoreItems- - 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 infoaCollection- - 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 infoaCollection- - 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 infoaCollection- - 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 infoaCollection- - 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 collectioncontext- - The search context- Returns:
- CollectionWithPagingInfo
-
getCollection
public Collection<T> getCollection()
Returns the Collection object- Specified by:
getCollectionin interfaceSerializablePagedCollection<T>- Returns:
- Collection
-
hasMoreItems
public boolean hasMoreItems()
Indicates if the returned collection has more items after the current returned list.- Specified by:
hasMoreItemsin interfaceSerializablePagedCollection<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:
getTotalItemsin interfaceSerializablePagedCollection<T>
-
getSourceEntity
public Object getSourceEntity()
The parent/source entity responsible for the collection- Specified by:
getSourceEntityin interfaceSerializablePagedCollection<T>
-
getPaging
public Paging getPaging()
The requested paging parameters set by the client- Specified by:
getPagingin interfaceSerializablePagedCollection<T>
-
getContext
public SearchContext getContext()
Description copied from interface:SerializablePagedCollectionThe search context for the collection- Specified by:
getContextin interfaceSerializablePagedCollection<T>
-
-