T
- the type of objects to retrieve@API(status=INTERNAL)
public class PaginatedService<T>
extends java.lang.Object
PaginatedApi
.
Goal is to fetch elements lazily.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PAGINATION_CHUNK_SIZE |
static int |
DEFAULT_PAGINATION_TOTAL_SIZE |
Constructor and Description |
---|
PaginatedService(PaginatedApi<T> paginatedApi,
int chunkSize,
int maxSize)
The only constructor
|
Modifier and Type | Method and Description |
---|---|
java.util.Iterator<T> |
iterator()
Returns an iterator of elements with lazy fetching.
|
java.util.stream.Stream<T> |
stream()
Returns an stream of elements with lazy fetching.
|
public static final int DEFAULT_PAGINATION_CHUNK_SIZE
public static final int DEFAULT_PAGINATION_TOTAL_SIZE
public PaginatedService(PaginatedApi<T> paginatedApi, int chunkSize, int maxSize)
paginatedApi
- the paginated api used to retrieve the chunks of elementschunkSize
- the maximum number to retrieve in one call of PaginatedApi.get(int, int)
maxSize
- the maximum number to retrieve in totalpublic java.util.Iterator<T> iterator()
Iterator
which lazily makes calls to the PaginatedApi
.public java.util.stream.Stream<T> stream()
Stream
which lazily makes calls to the PaginatedApi
.