com.stripe.model.PagingIterable Maven / Gradle / Ivy
package com.stripe.model;
import com.stripe.net.StripeResponseGetter;
import java.lang.reflect.Type;
import java.util.Iterator;
/**
* Provides an {@code Iterable}
target that automatically iterates across all API
* pages and which is suitable for use with a {@code foreach}
loop.
*/
public class PagingIterable implements Iterable {
private final StripeCollectionInterface page;
private final StripeResponseGetter responseGetter;
private final Type pageType;
PagingIterable(
final StripeCollectionInterface page, StripeResponseGetter responseGetter, Type pageType) {
this.page = page;
this.responseGetter = responseGetter;
this.pageType = pageType;
}
@Override
public Iterator iterator() {
return new PagingIterator<>(page, responseGetter, pageType);
}
}