> + marker = set.getNextMarker();
> + iterator = set.iterator();
> + }
> +
> + @Override
> + public boolean hasNext() {
> + return iterator.hasNext() || marker != null;
> + }
> +
> + @Override
> + public StorageMetadata next() {
> + while (true) {
> + if (!iterator.hasNext()) {
> + advance();
> + }
> + StorageMetadata metadata = iterator.next();
Looking at your implementation, that shouldn't be needed. That concat would
substitute your `while(true)` loop.
In the links I passed as an example, you have an `Iterator<Page<T>>`, that is,
an iterator that knows how to "fetch pages", but does not iterate the elements
of each page. The `concat` method is used to "flatten" that iterator in an
iterator that iterates over the element of each page and jumps to the next one
once finished. Basically, if you model it to be an Iterator of pages (which is
what it really is), you can take benefit of Guava's
`Iterators.concat(Iterator)` to do the "jump from one page to the next one" for
you.
It is just an implementation detail. I just shared how pagination is
implemented in other parts of the code (which IMO ends up being simpler code).
The current implementation looks fine, BTW :)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/702/files#r28673416