@Test public void route53ResourceRecordSets() throws Exception { SortedSet<String> pages = newPageSet(5); final Iterator<String> reqIt = pages.iterator(); final Iterator<String> resIt = pages.iterator(); Function<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> f = r -> { if (r.getStartRecordName() != null) { String expected = reqIt.next(); Assert.assertEquals(expected + "-id", r.getStartRecordIdentifier()); Assert.assertEquals(expected + "-name", r.getStartRecordName()); Assert.assertEquals(expected + "-type", r.getStartRecordType()); } String next = resIt.hasNext() ? resIt.next() : null; return new ListResourceRecordSetsResult() .withNextRecordIdentifier((next != null) ? next + "-id" : null) .withNextRecordName((next != null) ? next + "-name" : null) .withNextRecordType((next != null) ? next + "-type" : null); }; Publisher<ListResourceRecordSetsResult> publisher = Pagination.createPublisher(new ListResourceRecordSetsRequest(), f); Iterable<String> iter = Flowable.fromPublisher(publisher) .filter(r -> r.getNextRecordName() != null) .map(ListResourceRecordSetsResult::getNextRecordName) .blockingIterable(); SortedSet<String> results = new TreeSet<>(); for (String s : iter) { results.add(s.substring(0, 5)); } 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);  }