use of com.datastax.oss.driver.internal.core.cql.DefaultPagingState in project java-driver by datastax.
the class ExecutionInfo method getSafePagingState.
/**
* The paging state of the query, in a safe wrapper that checks if it's reused on the right
* statement.
*
* <p>This represents the next page to be fetched if this query has multiple page of results. It
* can be saved and reused later on the same statement.
*
* @return the paging state, or {@code null} if there is no next page.
*/
@Nullable
default PagingState getSafePagingState() {
// Default implementation for backward compatibility, but we override it in the concrete class,
// because it knows the attachment point.
ByteBuffer rawPagingState = getPagingState();
if (rawPagingState == null) {
return null;
} else {
Request request = getRequest();
if (!(request instanceof Statement)) {
throw new IllegalStateException("Only statements should have a paging state");
}
Statement<?> statement = (Statement<?>) request;
return new DefaultPagingState(rawPagingState, statement, AttachmentPoint.NONE);
}
}
Aggregations