Example usage for org.springframework.data.domain Pageable next

List of usage examples for org.springframework.data.domain Pageable next

Introduction

In this page you can find the example usage for org.springframework.data.domain Pageable next.

Prototype

Pageable next();

Source Link

Document

Returns the Pageable requesting the next Page .

Usage

From source file:org.openlmis.fulfillment.AuditLogInitializer.java

private void createSnapshots(PagingAndSortingRepository<?, ?> repository) {
    Pageable pageable = new PageRequest(DEFAULT_PAGE_NUMBER, 2000);

    while (true) {
        Page<?> page = repository.findAll(pageable);

        if (!page.hasContent()) {
            break;
        }// w  ww .  j a va2s  .c om

        page.forEach(this::createSnapshot);

        pageable = pageable.next();
    }
}

From source file:org.wallride.web.support.Pagination.java

public List<Pageable> getPageables(Pageable currentPageable, int interval) {
    List<Pageable> pageables = new ArrayList<>();

    int start = page.getNumber() - interval;
    if (start < 0) {
        start = 0;//from  w w w  .ja v  a  2s  . c  o m
    }
    int end = page.getNumber() + interval;
    if (end > page.getTotalPages() - 1) {
        end = page.getTotalPages() - 1;
    }

    Pageable p;
    p = currentPageable;
    for (int i = getCurrentPageNumber(); i > start; i--) {
        p = p.previousOrFirst();
        pageables.add(p);
    }

    Collections.reverse(pageables);
    pageables.add(currentPageable);

    p = currentPageable;
    for (int i = getCurrentPageNumber(); i < end; i++) {
        p = p.next();
        pageables.add(p);
    }

    return pageables;
}