当前位置: 首页>>代码示例>>Java>>正文


Java Page.hasNext方法代码示例

本文整理汇总了Java中org.springframework.data.domain.Page.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java Page.hasNext方法的具体用法?Java Page.hasNext怎么用?Java Page.hasNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.domain.Page的用法示例。


在下文中一共展示了Page.hasNext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addPaginationData

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public HttpHeaders addPaginationData(HttpHeaders headers, Page<?> page) {
	addHeaderAndLog(headers, ApiHttpHeaders.TOTAL_COUNT, this.totalCountHeaderBuilder.buildTotal(page));

	if (!page.isFirst()) {
		addHeaderAndLog(headers, ApiHttpHeaders.LINK, this.linkHeaderBuilder.buildFirst());
	}

	if (!page.isLast()) {
		addHeaderAndLog(headers, ApiHttpHeaders.LINK, this.linkHeaderBuilder.buildLast(page));
	}

	if (page.hasPrevious()) {
		addHeaderAndLog(headers, ApiHttpHeaders.LINK, this.linkHeaderBuilder.buildPrev(page));
	}

	if (page.hasNext()) {
		addHeaderAndLog(headers, ApiHttpHeaders.LINK, this.linkHeaderBuilder.buildNext(page));
	}

	return headers;
}
 
开发者ID:cmateosl,项目名称:role-api,代码行数:26,代码来源:HateoasPaginationHeadersBuilder.java

示例2: doSubjectMigration

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public void doSubjectMigration(final SubjectRepository subjectRepository,
        final GraphSubjectRepository subjectHierarchicalRepository, final int pageSize) {
    int numOfSubjectsSaved = 0;
    Pageable pageRequest = new PageRequest(0, pageSize, new Sort("id"));
    long numOfSubjectEntitiesToMigrate = subjectRepository.count();
    Page<SubjectEntity> pageOfSubjects;

    do {
        pageOfSubjects = subjectRepository.findAll(pageRequest);
        List<SubjectEntity> subjectListToSave = pageOfSubjects.getContent();
        numOfSubjectsSaved += pageOfSubjects.getNumberOfElements();
        subjectListToSave.forEach(item -> {
            item.setId(0);
            LOGGER.trace("doSubjectMigration Subject-Id: {} Zone-name: {} Zone-id: {}", item.getSubjectIdentifier(),
                    item.getZone().getName(), item.getZone().getId());
        });

        subjectHierarchicalRepository.save(subjectListToSave);
        LOGGER.info("Total subjects migrated so far: {}/{}", numOfSubjectsSaved, numOfSubjectEntitiesToMigrate);
        pageRequest = pageOfSubjects.nextPageable();
    } while (pageOfSubjects.hasNext());

    LOGGER.info("Number of subject entities migrated: {}", numOfSubjectsSaved);
    LOGGER.info("Subject migration to Titan completed.");
}
 
开发者ID:eclipse,项目名称:keti,代码行数:26,代码来源:SubjectMigrationManager.java

示例3: fromPage

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
/**
 * Converts the given page into a ContinuableListing
 * @param page The page.
 */
public static <T> ContinuableListing<T> fromPage(Page<T> page){
    ContinuationToken currentToken = fromPageable(page.getPageable());
    ContinuationToken nextToken = null;
    if(page.hasNext()){
        nextToken = fromPageable(page.getPageable().next());
    }

    if(nextToken != null){
        return ContinuableListing.continuable(page.getContent(), page.getSize(), currentToken, nextToken);
    }else{
        return ContinuableListing.finiteChunk(page.getContent(), page.getSize(), currentToken);
    }
}
 
开发者ID:ElderByte-,项目名称:spring-cloud-starter-bootstrap,代码行数:18,代码来源:ContinuationSupport.java

示例4: getAllBooks

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
@GetMapping
public ResponseEntity<List<Book>> getAllBooks(
        @PageableDefault(size = MAX_PAGE_SIZE) Pageable pageable,
        @RequestParam(required = false, defaultValue = "id") String sort,
        @RequestParam(required = false, defaultValue = "asc") String order) {
    final PageRequest pr = PageRequest.of(
            pageable.getPageNumber(), pageable.getPageSize(),
            Sort.by("asc" .equals(order) ? Sort.Direction.ASC : Sort.Direction.DESC, sort)
    );

    Page<Book> booksPage = bookRepository.findAll(pr);

    if (booksPage.getContent().isEmpty()) {
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    } else {
        long totalBooks = booksPage.getTotalElements();
        int nbPageBooks = booksPage.getNumberOfElements();

        HttpHeaders headers = new HttpHeaders();
        headers.add("X-Total-Count", String.valueOf(totalBooks));

        if (nbPageBooks < totalBooks) {
            headers.add("first", buildPageUri(PageRequest.of(0, booksPage.getSize())));
            headers.add("last", buildPageUri(PageRequest.of(booksPage.getTotalPages() - 1, booksPage.getSize())));

            if (booksPage.hasNext()) {
                headers.add("next", buildPageUri(booksPage.nextPageable()));
            }

            if (booksPage.hasPrevious()) {
                headers.add("prev", buildPageUri(booksPage.previousPageable()));
            }

            return new ResponseEntity<>(booksPage.getContent(), headers, HttpStatus.PARTIAL_CONTENT);
        } else {
            return new ResponseEntity(booksPage.getContent(), headers, HttpStatus.OK);
        }
    }
}
 
开发者ID:sbouclier,项目名称:java-rest-books,代码行数:40,代码来源:BookController.java

示例5: doResourceMigration

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public void doResourceMigration(final ResourceRepository resourceRepository,
        final GraphResourceRepository resourceHierarchicalRepository, final int pageSize) {
    int numOfResourcesSaved = 0;
    Pageable pageRequest = new PageRequest(0, pageSize, new Sort("id"));
    long numOfResourceEntitiesToMigrate = resourceRepository.count();
    Page<ResourceEntity> pageOfResources;

    do {
        pageOfResources = resourceRepository.findAll(pageRequest);
        List<ResourceEntity> resourceListToSave = pageOfResources.getContent();
        numOfResourcesSaved += pageOfResources.getNumberOfElements();

        resourceListToSave.forEach(item -> {
            // Clear the auto-generated id field prior to migrating to graphDB
            item.setId((long) 0);
            LOGGER.trace("doResourceMigration Resource-Id: {} Zone-name: {} Zone-id: {}",
                    item.getResourceIdentifier(), item.getZone().getName(), item.getZone().getId());
        });

        resourceHierarchicalRepository.save(resourceListToSave);

        LOGGER.info("Total resources migrated so far: {}/{}", numOfResourcesSaved, numOfResourceEntitiesToMigrate);
        pageRequest = pageOfResources.nextPageable();
    } while (pageOfResources.hasNext());

    LOGGER.info("Number of resource entities migrated: {}", numOfResourcesSaved);
    LOGGER.info("Resource migration to Titan completed.");
}
 
开发者ID:eclipse,项目名称:keti,代码行数:29,代码来源:ResourceMigrationManager.java


注:本文中的org.springframework.data.domain.Page.hasNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。