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

The following examples show how to use org.springframework.data.domain.Page#isFirst() . 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: PageResponseBodyAdvisor.java    From spring-boot-jpa with Apache License 2.0 5 votes vote down vote up
private Optional<String> getHttpHeaderLinksString(ServerHttpRequest request, Page<?> page) {
	List<String> headerLinks = new ArrayList<>();

	if (!page.isFirst()) {
		headerLinks.add(String.format(LINK_STANDARD_FMT, UriComponentsBuilder.fromHttpRequest(request)
				.replaceQueryParam(QUERY_PARAM_PAGE, 0)
				.build(), LINK_HEADER_FIRST));
	}

	if (page.hasPrevious()) {
		headerLinks.add(String.format(LINK_STANDARD_FMT, UriComponentsBuilder.fromHttpRequest(request)
				.replaceQueryParam(QUERY_PARAM_PAGE, page.previousPageable().getPageNumber())
				.build(), LINK_HEADER_PREVIOUS));
	}

	if (page.hasNext()) {
		headerLinks.add(String.format(LINK_STANDARD_FMT, UriComponentsBuilder.fromHttpRequest(request)
				.replaceQueryParam(QUERY_PARAM_PAGE, page.nextPageable().getPageNumber())
				.build(), LINK_HEADER_NEXT));
	}

	if (!page.isLast()) {
		headerLinks.add(String.format(LINK_STANDARD_FMT, UriComponentsBuilder.fromHttpRequest(request)
				.replaceQueryParam(QUERY_PARAM_PAGE, page.getTotalPages() - 1)
				.build(), LINK_HEADER_LAST));
	}

	return Optional.of(StringUtils.join(headerLinks, ", "));
}
 
Example 2
Source File: PlatformPageImpl.java    From abixen-platform with GNU Lesser General Public License v2.1 5 votes vote down vote up
public PlatformPageImpl(Page page) {
    super(page.getContent(),
            new PageRequest(page.getNumber(), page.getSize(), page.getSort()),
            page.getTotalElements());
    this.number = page.getNumber();
    this.size = page.getSize();
    this.totalPages = page.getTotalPages();
    this.numberOfElements = page.getNumberOfElements();
    this.totalElements = page.getTotalElements();
    this.first = page.isFirst();
    this.last = page.isLast();
    this.content = page.getContent();
    this.sort = page.getSort();
}
 
Example 3
Source File: PageUtils.java    From thymeleaf-spring-data-dialect with Apache License 2.0 5 votes vote down vote up
public static boolean isFirstPage(Page<?> page) {
		if( page.getTotalPages()==0 ) {
			return true;
		}
		
		return page.isFirst();
}