use of com.google.cloud.spring.data.datastore.repository.query.DatastorePageable in project spring-cloud-gcp by GoogleCloudPlatform.
the class DatastoreTemplate method applyPageable.
private StructuredQuery applyPageable(StructuredQuery query, Pageable pageable) {
if (pageable == Pageable.unpaged()) {
return query;
}
Cursor cursor = null;
if (pageable instanceof DatastorePageable) {
cursor = ((DatastorePageable) pageable).toCursor();
}
StructuredQuery.Builder builder = query.toBuilder();
if (cursor != null) {
builder.setStartCursor(cursor).setOffset(0);
} else {
builder.setOffset(Math.toIntExact(pageable.getOffset()));
}
return builder.setLimit(pageable.getPageSize()).build();
}
Aggregations