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
Modifier and TypeClassDescriptionstatic class
Builds PagedResponse's of T -
Constructor Summary
-
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 elementboolean
Indicates whether the source has more results after this page.iterator()
<M> PagedResponse<M>
Allows you to map a paged response of T into Mint
size()
static <T> PagedResponse<T>
sortAndToPagedResponse
(LimitedPagedRequest limitedPagedRequest, List<T> items, Comparator<T> comparator) Use the providedComparator
to 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, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PagedResponseImpl
-
-
Method Details
-
getPagedRequest
- Specified by:
getPagedRequest
in interfacePagedResponse<T>
- Returns:
- the request used to produce this response
-
iterator
-
size
public int size()- Specified by:
size
in interfacePagedResponse<T>
- Returns:
- the number of results in this page of results
-
getResults
- Specified by:
getResults
in interfacePagedResponse<T>
- Returns:
- the results
-
hasNextPage
public boolean hasNextPage()Description copied from interface:PagedResponse
Indicates whether the source has more results after this page.- Specified by:
hasNextPage
in interfacePagedResponse<T>
- Returns:
- true if there are more results
-
map
Description copied from interface:PagedResponse
Allows you to map a paged response of T into M- Specified by:
map
in interfacePagedResponse<T>
- Type Parameters:
M
- the output type- Parameters:
mapper
- the mapping function- Returns:
- a paged response of M
-
findFirst
- Specified by:
findFirst
in 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
PagedResponse
that is of the limited size
-
sortAndToPagedResponse
public static <T> PagedResponse<T> sortAndToPagedResponse(LimitedPagedRequest limitedPagedRequest, List<T> items, Comparator<T> comparator) Use the providedComparator
to sort and reduces a list of items to the system enforced limited page size.- Returns:
- a
PagedResponse
that 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...
-