Pages { public static <E, X extends Exception> Stream<E> stream(PageSupplier<E, X> supplier, int size) throws X { return eagerFetch(supplier, size).stream(); } 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 eagerlyStreamsAllElements() { List<String> result = Pages.stream(testSource::getStrings, 2).collect(Collectors.toList()); assertEquals(result, testSource.strings); }
@Test public void returnsEmptyStreamWhenFetchingEagerly() { Stream<String> stream = Pages.stream(new TestPagesSupplier()::getStrings); assertFalse(stream.findAny().isPresent()); }