@Test public void lambda() throws Exception { SortedSet<String> pages = newPageSet(5); final Iterator<String> reqIt = pages.iterator(); final Iterator<String> resIt = pages.iterator(); Function<ListFunctionsRequest, ListFunctionsResult> f = r -> { if (r.getMarker() != null) { Assert.assertEquals(reqIt.next(), r.getMarker()); } return new ListFunctionsResult() .withNextMarker(resIt.hasNext() ? resIt.next() : null); }; Publisher<ListFunctionsResult> publisher = Pagination.createPublisher(new ListFunctionsRequest(), f); Iterable<String> iter = Flowable.fromPublisher(publisher) .filter(r -> r.getNextMarker() != null) .map(ListFunctionsResult::getNextMarker) .blockingIterable(); SortedSet<String> results = new TreeSet<>(); for (String s : iter) { results.add(s); } Assert.assertEquals(pages, results); Assert.assertFalse(reqIt.hasNext()); }
public static <R, T> Publisher<T> createPublisher(R request, Function<R, T> f) { return createPublisher(DEFAULT_POOL, request, f); }
Pagination { public static <R, T> Publisher<T> createPublisher(R request, Function<R, T> f) { return createPublisher(DEFAULT_POOL, request, f); } }
Pagination { public static <R, T> Publisher<T> createPublisher(R request, Function<R, T> f) { return createPublisher(DEFAULT_POOL, request, f); } private  Pagination(); }
Pagination { public static <R, T> Publisher<T> createPublisher(R request, Function<R, T> f) { return createPublisher(DEFAULT_POOL, request, f); } private  Pagination(); static Iterator<T> createIterator(R request, Function<R, T> f); static Iterable<T> createIterable(R request, Function<R, T> f); static Publisher<T> createPublisher(R request, Function<R, T> f); static Publisher<T> createPublisher(Executor executor, R request, Function<R, T> f); }
Pagination { public static <R, T> Publisher<T> createPublisher(R request, Function<R, T> f) { return createPublisher(DEFAULT_POOL, request, f); } private  Pagination(); static Iterator<T> createIterator(R request, Function<R, T> f); static Iterable<T> createIterable(R request, Function<R, T> f); static Publisher<T> createPublisher(R request, Function<R, T> f); static Publisher<T> createPublisher(Executor executor, R request, Function<R, T> f);  }