Package com.abiquo.apiclient.domain
Class PageIterator<T extends com.abiquo.model.transport.WrapperDto<? extends com.abiquo.model.transport.SingleResourceTransportDto>>
- java.lang.Object
-
- com.google.common.collect.UnmodifiableIterator<T>
-
- com.google.common.collect.AbstractIterator<T>
-
- com.abiquo.apiclient.domain.PageIterator<T>
-
- All Implemented Interfaces:
Iterator<T>
public class PageIterator<T extends com.abiquo.model.transport.WrapperDto<? extends com.abiquo.model.transport.SingleResourceTransportDto>> extends com.google.common.collect.AbstractIterator<T>AnIteratorthat is capable of advancing between the pages of a paginated collection.To create this iterator use the
#flatten(ApiClient, WrapperDto)method.- Author:
- Ignasi Barrera
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPageIterator.AdvancingIterable<T extends com.abiquo.model.transport.SingleResourceTransportDto,W extends com.abiquo.model.transport.WrapperDto<T>>AnIterablethat is capable of advancing between pages.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TcomputeNext()static <T extends com.abiquo.model.transport.SingleResourceTransportDto,W extends com.abiquo.model.transport.WrapperDto<T>>
Stream<T>flatten(RestClient api, W dto)Creates an Stream capable of advancing over the elements of a paginated collection, and lazily fetch new pages as they are needed.-
Methods inherited from class com.google.common.collect.AbstractIterator
endOfData, hasNext, next, peek
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Method Detail
-
computeNext
protected T computeNext()
- Specified by:
computeNextin classcom.google.common.collect.AbstractIterator<T extends com.abiquo.model.transport.WrapperDto<? extends com.abiquo.model.transport.SingleResourceTransportDto>>
-
flatten
public static <T extends com.abiquo.model.transport.SingleResourceTransportDto,W extends com.abiquo.model.transport.WrapperDto<T>> Stream<T> flatten(RestClient api, W dto)
Creates an Stream capable of advancing over the elements of a paginated collection, and lazily fetch new pages as they are needed.- Parameters:
api- The rest client used to fetch new pages when needed.dto- The collection to iterate.- Returns:
- An iterator capable of advancing between pages.
-
-