MapWhileCursor implements RecordCursor<V> { @Nullable @Override @SpotBugsSuppressWarnings("EI_EXPOSE_REP") @Deprecated public byte[] getContinuation() { return nextResult.getContinuation().toBytes(); } @SpotBugsSuppressWarnings("EI_EXPOSE_REP2") @SuppressWarnings("PMD.UnusedFormalParameter") // for compatibility reasons  MapWhileCursor(@Nonnull RecordCursor<T> inner, @Nonnull Function<T, Optional<V>> func,
                          @Nonnull StopContinuation stopContinuation, @Nullable byte[] initialContinuation,
                          @Nonnull NoNextReason noNextReason); @Nonnull @Override CompletableFuture<RecordCursorResult<V>> onNext(); @Nonnull @Override @Deprecated CompletableFuture<Boolean> onHasNext(); @Nullable @Override @Deprecated V next(); @Nullable @Override @SpotBugsSuppressWarnings("EI_EXPOSE_REP") @Deprecated byte[] getContinuation(); @Nonnull @Override @Deprecated NoNextReason getNoNextReason(); @Override void close(); @Nonnull @Override Executor getExecutor(); @Override boolean accept(@Nonnull RecordCursorVisitor visitor);  }
@Test public void stopAndContinue() { RecordCursor<Integer> cursor = newCursor(i -> i > 2, null, MapWhileCursor.StopContinuation.AFTER, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED); assertEquals(Arrays.asList(2, 3), cursor.asList().join()); validateNoNextReason(cursor, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED); cursor = newCursor(i -> i > 5, cursor.getNext().getContinuation().toBytes(), MapWhileCursor.StopContinuation.AFTER, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED); assertEquals(Arrays.asList(5, 6), cursor.asList().join()); validateNoNextReason(cursor, RecordCursor.NoNextReason.SOURCE_EXHAUSTED); }
@Test public void stopAndRepeat() { RecordCursor<Integer> cursor = newCursor(i -> i > 2, null, MapWhileCursor.StopContinuation.BEFORE, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED); assertEquals(Arrays.asList(2, 3), cursor.asList().join()); validateNoNextReason(cursor, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED); cursor = newCursor(i -> i > 4, cursor.getNext().getContinuation().toBytes(), MapWhileCursor.StopContinuation.BEFORE, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED); assertEquals(Arrays.asList(4, 5), cursor.asList().join()); validateNoNextReason(cursor, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED); cursor = newCursor(i -> i > 10, cursor.getNext().getContinuation().toBytes(), MapWhileCursor.StopContinuation.BEFORE, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED); assertEquals(Arrays.asList(6), cursor.asList().join()); validateNoNextReason(cursor, RecordCursor.NoNextReason.SOURCE_EXHAUSTED); }