@Test public void cloudwatchPut() throws Exception { final AtomicInteger n = new AtomicInteger(); Function<PutMetricDataRequest, PutMetricDataResult> f = r -> { if (n.getAndIncrement() > 0) { Assert.fail("non-paginated API called more than once"); } return new PutMetricDataResult(); }; Publisher<PutMetricDataResult> publisher = Pagination.createPublisher(new PutMetricDataRequest(), f); Iterable<PutMetricDataResult> iter = Flowable.fromPublisher(publisher).blockingIterable(); int count = 0; for (PutMetricDataResult r : iter) { ++count; } Assert.assertEquals(1, count); }
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);  }