Pages { public static <E, X extends Exception> Iterable<E> iterate(PageSupplier<E, X> supplier, int size) throws X { return eagerFetch(supplier, size); } private  Pages(); static Stream<E> stream(PageSupplier<E, X> supplier, int size); static Stream<E> stream(PageSupplier<E, X> supplier); static Iterable<E> iterate(PageSupplier<E, X> supplier, int size); static Iterable<E> iterate(PageSupplier<E, X> supplier); static Stream<E> streamLazily(
      PageSupplier<E, X> supplier, int size); static Stream<E> streamLazily(PageSupplier<E, X> supplier); static Iterable<E> iterateLazily(
      PageSupplier<E, X> supplier, int size); static Iterable<E> iterateLazily(PageSupplier<E, X> supplier); static final int DEFAULT_PAGE_SIZE; }
@Test public void eagerlyIteratesAllElements() throws Exception { ArrayList<String> result = Lists.newArrayList(Pages.iterate(testSource::getStrings, 2)); assertEquals(result, testSource.strings); }
@Test public void returnsIterableWithNoElementsWhileFetchingEagerly() { Iterator<String> it = Pages.iterate(new TestPagesSupplier()::getStrings).iterator(); assertFalse(it.hasNext()); }