List of usage examples for org.springframework.data.domain Pageable getPageSize
int getPageSize();
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.//from w w w. ja v a 2 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: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. *//* ww w. j a v a 2 s . c o m*/ public static int getStartIndex(final Pageable pageable) { return (pageable.getPageNumber() * pageable.getPageSize()) + 1; }
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 end index from the pageable object. *//*from w w w. j a va 2s .com*/ 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
/** * Check (and adjust) the values of a {@link Pageable} object. Check that: * <ul>//from w w w . j av a2 s . co 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:cat.albirar.framework.utilities.PageUtilities.java
/** * Clone a {@link Pageable} object.//w ww. ja v a 2 s.co 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:io.pivotal.strepsirrhini.chaosloris.docs.DocumentationUtilities.java
static <T> Page<T> page(Pageable pageable, LongFunction<T> function) { return new PageImpl<>(LongStream.range(pageable.getOffset(), pageable.getOffset() + pageable.getPageSize()) .mapToObj(function).collect(Collectors.toList()), pageable, 12); }
From source file:org.openlmis.fulfillment.util.Pagination.java
/** * Returns the pageSize of the specified pageable. *//* ww w . j a v a 2 s. c om*/ public static int getPageSize(Pageable pageable) { if (pageable == null) { return NO_PAGINATION; } else { return pageable.getPageSize(); } }
From source file:com.trenako.results.PaginatedLists.java
/** * Returns a values page according the provided {@code Pageable}. * * @param values the values to be paginated * @param paging the paging information//from ww w .j av a 2 s . c o m * @return a {@code Page} */ public static <T> Page<T> paginate(List<T> values, Pageable paging) { Assert.notNull(values, "Values list must be not null"); int total = values.size(); int offset = paging.getOffset(); if (offset > total) { return failbackPage(); } int sIndex = start(total, offset); int eIndex = end(total, offset, paging.getPageSize()); List<T> content = values.subList(sIndex, eIndex); return new PageImpl<>(content, paging, total); }