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

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

Introduction

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

Prototype

int getPageNumber();

Source Link

Document

Returns the page to be returned.

Usage

From source file:org.seasar.doma.boot.Pageables.java

/**
 * Converts {@link Pageable} to {@link SelectOptions}
 *
 * @param pageable {@link Pageable} object to convert
 * @return {@link SelectOptions} object corresponds to the given {@link Pageable}
 * object.//  w w  w  .ja v a2 s. c  o m
 */
public static SelectOptions toSelectOptions(Pageable pageable) {
    final int offset = pageable.getPageNumber() * pageable.getPageSize();
    final int limit = pageable.getPageSize();
    return SelectOptions.get().offset(offset).limit(limit);
}

From source file:com.wiiyaya.framework.provider.utils.PageableHelper.java

public static Pageable cloneWithoutOrder(Pageable pageRequest) {
    return new PageRequest(pageRequest.getPageNumber(), pageRequest.getPageSize());
}

From source file:io.kahu.hawaii.util.pagination.PaginationHelper.java

/**
 * Calculates the start index from the pageable object. As rownums start with 1 we add 1 to the result of page number * page size.
 *///  w w w . jav a  2 s.c o  m
public static int getStartIndex(final Pageable pageable) {
    return (pageable.getPageNumber() * pageable.getPageSize()) + 1;
}

From source file:io.kahu.hawaii.util.pagination.PaginationHelper.java

/**
 * Calculates the end index from the pageable object.
 *//*  www .j a  va 2s  . c om*/
public static int getEndIndex(final Pageable pageable) {
    return (pageable.getPageNumber() + 1) * pageable.getPageSize();
}

From source file:io.pivotal.strepsirrhini.chaosloris.docs.DocumentationUtilities.java

static String query(Pageable pageable) {
    return String.format("?page=%d&size=%d", pageable.getPageNumber(), pageable.getPageSize());
}

From source file:cat.albirar.framework.utilities.PageUtilities.java

/**
 * Clone a {@link Pageable} object./*from w w  w.j av a  2  s .  c o  m*/
 * 
 * @param origin The origin
 * @return The new instance with all the origin values. Null if origin is null
 */
public static final Pageable copyPageable(Pageable origin) {
    Pageable d;

    if (origin != null) {
        d = new PageRequest(origin.getPageNumber(), origin.getPageSize(), origin.getSort());
    } else {
        d = null;
    }
    return d;
}

From source file:ts.utils.PageUtil.java

public static Map<String, Integer> pageNavigation(Page<?> page, Pageable pageable) {
    Map<String, Integer> attributes = new HashMap<>();
    attributes.put("pageTotal", page.getTotalPages() - 1);
    attributes.put("pageNext", pageable.getPageNumber() + 1);
    attributes.put("pageBack", pageable.getPageNumber() - 1);
    attributes.put("activePage", page.getNumber());
    return attributes;
}

From source file:org.openlmis.fulfillment.util.Pagination.java

/**
 * Returns the pageNumber of the specified pageable.
 *///from ww w  . j a v a 2s. co  m
public static int getPageNumber(Pageable pageable) {
    if (pageable == null) {
        return DEFAULT_PAGE_NUMBER;
    } else {
        return pageable.getPageNumber();
    }
}

From source file:cat.albirar.framework.utilities.PageUtilities.java

/**
 * Check (and adjust) the values of a {@link Pageable} object. Check that:
 * <ul>//  w  w w. jav a  2  s. c o m
 * <li>{@link Pageable#getPageSize() origin.getPageSize()} is equals or great than one</li>
 * <li>{@link Pageable#getPageNumber() origin.getPageNumber()} is equals or great than zero</li>
 * </ul>
 * <strong>WARNING!!</strong> {@link Pageable} is immutable, so you should to use the same returned object
 * 
 * @param origin The origin
 * @return A new instance, amended if needed. Null in case that origin is null
 */
public static final Pageable checkAndAdjust(Pageable origin) {
    int elements, pagina;

    if (origin != null) {
        if (origin.getPageSize() < 1) {
            elements = PAGE_SIZE;
        } else {
            elements = origin.getPageSize();
        }

        if (origin.getPageNumber() < 0) {
            pagina = 0;
        } else {
            pagina = origin.getPageNumber();
        }
        return new PageRequest(pagina, elements);
    }
    return null;
}

From source file:com.wiiyaya.framework.provider.utils.PageableHelper.java

public static Pageable mappingAttr(Map<String, String> replaceAttr, Pageable pageRequest) {
    if (pageRequest.getSort() == null || replaceAttr == null || replaceAttr.size() == 0) {
        return pageRequest;
    }/*from  w w w  .j  a v a 2 s .com*/
    List<Order> orders = new ArrayList<Order>();

    for (Map.Entry<String, String> entry : replaceAttr.entrySet()) {
        Order ctOrd = pageRequest.getSort().getOrderFor(entry.getKey());
        if (ctOrd != null) {
            ctOrd = new Order(ctOrd.getDirection(), entry.getValue());
            orders.add(ctOrd);
        }
    }
    return new PageRequest(pageRequest.getPageNumber(), pageRequest.getPageSize(), new Sort(orders));
}