All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.capitalone.dashboard.util.PaginationHeaderUtility Maven / Gradle / Ivy

There is a newer version: 3.7.33
Show newest version
package com.capitalone.dashboard.util;

import org.springframework.data.domain.Page;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;

@Component
public class PaginationHeaderUtility {

	public  HttpHeaders buildPaginationHeaders(Page page) {
		HttpHeaders headers = new HttpHeaders();
		headers.add("totalEntities", String.valueOf(page.getTotalElements()));
		headers.add("totalPages", String.valueOf(page.getTotalPages()));
		headers.add("lastPage", String.valueOf(page.isLast()));
		headers.add("pageSize", String.valueOf(page.getSize()));
		headers.add("currentPage", String.valueOf(page.getNumber()));
		headers.add("firstPage", String.valueOf(page.isFirst()));
		headers.add("nextPage", String.valueOf(page.hasNext()));

		return headers;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy