Java Code Examples for org.springframework.data.domain.Page#getPageable()

The following examples show how to use org.springframework.data.domain.Page#getPageable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConverterDtv.java    From ueboot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public <U> Response<Page<U>> map(Page<T> info, Function<? super T, ? extends U> converter) {
    List<U> listU = new LinkedList<>();
    info.forEach((o) -> {
        U u = converter.apply(o);
        listU.add(u);
    });
    Page<U> result = new PageImpl<>(listU, info.getPageable(), info.getTotalElements());
    BeanUtils.copyProperties(info, result);
    return new Response<>(result);
}
 
Example 2
Source File: JournalCommentServiceImpl.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Page<JournalCommentWithJournalVO> convertToWithJournalVo(Page<JournalComment> journalCommentPage) {
    Assert.notNull(journalCommentPage, "Journal comment page must not be null");

    // Convert the list
    List<JournalCommentWithJournalVO> journalCmtWithJournalVOS = convertToWithJournalVo(journalCommentPage.getContent());

    // Build and return
    return new PageImpl<>(journalCmtWithJournalVOS, journalCommentPage.getPageable(), journalCommentPage.getTotalElements());
}
 
Example 3
Source File: JournalServiceImpl.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Page<JournalWithCmtCountDTO> convertToCmtCountDto(Page<Journal> journalPage) {
    Assert.notNull(journalPage, "Journal page must not be null");

    // Convert
    List<JournalWithCmtCountDTO> journalWithCmtCountDTOS = convertToCmtCountDto(journalPage.getContent());

    // Build and return
    return new PageImpl<>(journalWithCmtCountDTOS, journalPage.getPageable(), journalPage.getTotalElements());
}
 
Example 4
Source File: PageTestUtils.java    From spring-data-cosmosdb with MIT License 5 votes vote down vote up
public static void validateLastPage(Page page, int pageSize) {
    final Pageable pageable = page.getPageable();

    assertThat(pageable).isInstanceOf(CosmosPageRequest.class);
    assertTrue(continuationTokenIsNull((CosmosPageRequest) pageable));
    assertThat(pageable.getPageSize()).isEqualTo(pageSize);
}
 
Example 5
Source File: PageTestUtils.java    From spring-data-cosmosdb with MIT License 5 votes vote down vote up
public static void validateNonLastPage(Page page, int pageSize) {
    final Pageable pageable = page.getPageable();

    assertThat(pageable).isInstanceOf(CosmosPageRequest.class);
    assertThat(((CosmosPageRequest) pageable).getRequestContinuation()).isNotNull();
    assertThat(((CosmosPageRequest) pageable).getRequestContinuation()).isNotBlank();
    assertThat(pageable.getPageSize()).isEqualTo(pageSize);
}
 
Example 6
Source File: AppSpecificMapper.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public Page<UserForm> mapToUserPage(Page<UserEntity> users) {
    return new PageImpl<>(users.stream().map(this::mapToUserForm).collect(Collectors.toList()), users.getPageable(), users.getTotalElements());
}
 
Example 7
Source File: ProductDtoAssembler.java    From market with MIT License 4 votes vote down vote up
public PageImpl<ProductDTO> toModel(Page<Product> page) {
	List<ProductDTO> dtoList = page.map(this::toModel).toList();
	return new PageImpl<>(dtoList, page.getPageable(), page.getTotalElements());
}
 
Example 8
Source File: OrderDtoAssembler.java    From market with MIT License 4 votes vote down vote up
public PageImpl<OrderDTO> toModel(Page<Order> page) {
	List<OrderDTO> dtoList = page.map(this::toModel).toList();
	return new PageImpl<>(dtoList, page.getPageable(), page.getTotalElements());
}
 
Example 9
Source File: SheetCommentServiceImpl.java    From halo with GNU General Public License v3.0 3 votes vote down vote up
@Override
public Page<SheetCommentWithSheetVO> convertToWithSheetVo(Page<SheetComment> sheetCommentPage) {
    Assert.notNull(sheetCommentPage, "Sheet comment page must not be null");

    return new PageImpl<>(convertToWithSheetVo(sheetCommentPage.getContent()), sheetCommentPage.getPageable(), sheetCommentPage.getTotalElements());

}
 
Example 10
Source File: PostCommentServiceImpl.java    From halo with GNU General Public License v3.0 3 votes vote down vote up
@Override
public Page<PostCommentWithPostVO> convertToWithPostVo(Page<PostComment> commentPage) {
    Assert.notNull(commentPage, "PostComment page must not be null");

    return new PageImpl<>(convertToWithPostVo(commentPage.getContent()), commentPage.getPageable(), commentPage.getTotalElements());

}
 
Example 11
Source File: AbstractLogic.java    From jump-the-queue with Apache License 2.0 3 votes vote down vote up
/**
 * Maps a {@link Page paginated list} of persistent entities to a {@link Page
 * paginated list} of transfer objects.
 *
 * @param       <T> is the generic type of the {@link AbstractTransferObject
 *              transfer object}.
 * @param       <E> is the generic type of the {@link PersistenceEntity entity}.
 * @param page  is the paginated list to map from.
 * @param clazz is the target class to map the paginated entities to.
 * @return a {@link Page paginated list of entity transfer objects}.
 */
protected <T extends Serializable, E extends PersistenceEntity<?>> Page<T> mapPaginatedEntityList(Page<E> page,
		Class<T> clazz) {

	List<T> etoList = getBeanMapper().mapList(page.getContent(), clazz);
	return new PageImpl<>(etoList, page.getPageable(), page.getTotalElements());
}