-
Notifications
You must be signed in to change notification settings - Fork 144
Closed
Labels
type:questionAn issue that's a questionAn issue that's a question
Description
Is your feature request related to a problem? Please describe the problem.
I am trying to write a generic method to fetch all elements of a collection. With v5 it was pretty easy:
public static <T, B extends BaseCollectionRequestBuilder<T, ?, ?, ?, ?>> List<T> fetchWholeCollection(B builder, Option... opt) {
Objects.requireNonNull(builder);
List<T> allObj = new ArrayList<>();
int i=0;
while (builder != null) {
BaseEntityCollectionRequest<T, ?, ?> req = (BaseEntityCollectionRequest<T, ?, ?>) builder.buildRequest(opt);
LOG.trace("#{} Url: {}", i, req.getRequestUrl());
BaseCollectionPage<T, ?> page = req.get();
List<T> chunk = page.getCurrentPage();
LOG.trace("#{} Count: {}", i, chunk.size());
allObj.addAll(chunk);
LOG.trace("#{} All count: {}", i, allObj.size());
builder = (B) page.getNextPage();
if (builder != null) {
LOG.trace("#{} Next builder: {}", i, builder.getRequestUrl());
i++;
} else {
LOG.trace("#{} Last call!", i);
}
}
return allObj;
}
How I can write a similar generic method with v6?
What I'm doing wrong?
Thanks
Describe the solution you'd like.
A common base class to be used to fetch all elements of a collection
Additional context?
No response
Metadata
Metadata
Assignees
Labels
type:questionAn issue that's a questionAn issue that's a question