Class PagedResponseImpl<T>
java.lang.Object
com.atlassian.servicedesk.api.util.paging.PagedResponseImpl<T>
- All Implemented Interfaces:
PagedResponse<T>,Iterable<T>
A wrapper around a list of content.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds PagedResponse's of T -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> PagedResponseImpl<T>empty(boolean hasMore) Returns an empty PagedResponse with the specified hasNextPage flagstatic <T> PagedResponseImpl<T>empty(boolean hasMore, LimitedPagedRequest request) Returns an empty PagedResponsestatic <T> PagedResponseImpl<T>empty(boolean hasMore, PagedRequest request) Returns an empty PagedResponsestatic <T> PagedResponse<T>filteredPageResponse(LimitedPagedRequest limitedPagedRequest, List<T> items, com.google.common.base.Predicate<? super T> predicate) Reduces a list of items for a limited request by the predicate provided.static <T> PagedResponseImpl.Builder<T>A builder of PagedResponse's that starts with the specified liststatic <T> PagedResponseImpl.Builder<T>fromSingle(boolean hasMore, T element) A builder of PagedResponse's that starts with the single elementbooleanIndicates whether the source has more results after this page.iterator()<M> PagedResponse<M>Allows you to map a paged response of T into Mintsize()static <T> PagedResponse<T>sortAndToPagedResponse(LimitedPagedRequest limitedPagedRequest, List<T> items, Comparator<T> comparator) Use the providedComparatorto sort and reduces a list of items to the system enforced limited page size.static <T> PagedResponse<T>toPagedResponse(LimitedPagedRequest limitedPagedRequest, List<T> items) Reduces a list of items to the system enforced limited page size.toString()static <F,T> PagedResponseImpl<T> transform(PagedResponse<F> input, com.google.common.base.Function<F, T> mapper) Converts a given PageResponse contains items of type F into an equivalent PageResponse with items of type T, transformed by the given mapper.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PagedResponseImpl
-
-
Method Details
-
getPagedRequest
- Specified by:
getPagedRequestin interfacePagedResponse<T>- Returns:
- the request used to produce this response
-
iterator
-
size
public int size()- Specified by:
sizein interfacePagedResponse<T>- Returns:
- the number of results in this page of results
-
getResults
- Specified by:
getResultsin interfacePagedResponse<T>- Returns:
- the results
-
hasNextPage
public boolean hasNextPage()Description copied from interface:PagedResponseIndicates whether the source has more results after this page.- Specified by:
hasNextPagein interfacePagedResponse<T>- Returns:
- true if there are more results
-
map
Description copied from interface:PagedResponseAllows you to map a paged response of T into M- Specified by:
mapin interfacePagedResponse<T>- Type Parameters:
M- the output type- Parameters:
mapper- the mapping function- Returns:
- a paged response of M
-
findFirst
- Specified by:
findFirstin interfacePagedResponse<T>- Returns:
- an optional first element of the paged response
-
toString
-
from
A builder of PagedResponse's that starts with the specified list- Parameters:
list- the starting elementshasMore- does it have more- Returns:
- a builder
-
fromSingle
A builder of PagedResponse's that starts with the single element- Parameters:
hasMore- does it have moreelement- the starting element- Returns:
- a builder
-
transform
public static <F,T> PagedResponseImpl<T> transform(PagedResponse<F> input, com.google.common.base.Function<F, T> mapper) Converts a given PageResponse contains items of type F into an equivalent PageResponse with items of type T, transformed by the given mapper. All other attributes of PageResponse are kept intact. -
empty
Returns an empty PagedResponse with the specified hasNextPage flag- Parameters:
hasMore- whether the response actually has more- Returns:
- n empty PagedResponse
-
empty
Returns an empty PagedResponse- Parameters:
hasMore- whether the response actually has morerequest- the input paged request- Returns:
- n empty PagedResponse
-
empty
Returns an empty PagedResponse- Parameters:
hasMore- whether the response actually has morerequest- the input paged request- Returns:
- n empty PagedResponse
-
toPagedResponse
public static <T> PagedResponse<T> toPagedResponse(LimitedPagedRequest limitedPagedRequest, List<T> items) Reduces a list of items to the system enforced limited page size. This method assume the items are sorted- Returns:
- a
PagedResponsethat is of the limited size
-
sortAndToPagedResponse
public static <T> PagedResponse<T> sortAndToPagedResponse(LimitedPagedRequest limitedPagedRequest, List<T> items, Comparator<T> comparator) Use the providedComparatorto sort and reduces a list of items to the system enforced limited page size.- Returns:
- a
PagedResponsethat is of the limited size
-
filteredPageResponse
public static <T> PagedResponse<T> filteredPageResponse(LimitedPagedRequest limitedPagedRequest, List<T> items, com.google.common.base.Predicate<? super T> predicate) Reduces a list of items for a limited request by the predicate provided. Useful for permission checks that are known to the Manager layer...
-