@Test public void testGetPageInfoOnePage() throws Exception { PageRequest pageRequest = PageRequest.of(1, 20); Page page = new PageImpl<>(new ArrayList<>(), pageRequest, 20); EmbeddedPageHeader embeddedPageHeader = new EmbeddedPageHeader("http: Map<String,Long> pageInfo = embeddedPageHeader.getPageInfo(); assertEquals(1, pageInfo.get("number").intValue()); assertEquals(20, pageInfo.get("size").intValue()); assertEquals(1, pageInfo.get("totalPages").intValue()); assertEquals(20, pageInfo.get("totalElements").intValue()); }
@JsonProperty(value = "page") public Map<String, Long> getPageInfo() { Map<String, Long> pageInfo = new HashMap<String, Long>(); pageInfo.put("number", (long) page.getNumber()); pageInfo.put("size", (long) page.getSize() != 0 ? page.getSize() : page.getTotalElements()); if (totalElementsIsKnown) { pageInfo.put("totalPages", (long) page.getTotalPages()); pageInfo.put("totalElements", page.getTotalElements()); } return pageInfo; }
EmbeddedPageHeader { @JsonProperty(value = "page") public Map<String, Long> getPageInfo() { Map<String, Long> pageInfo = new HashMap<String, Long>(); pageInfo.put("number", (long) page.getNumber()); pageInfo.put("size", (long) page.getSize() != 0 ? page.getSize() : page.getTotalElements()); if (totalElementsIsKnown) { pageInfo.put("totalPages", (long) page.getTotalPages()); pageInfo.put("totalElements", page.getTotalElements()); } return pageInfo; } }
EmbeddedPageHeader { @JsonProperty(value = "page") public Map<String, Long> getPageInfo() { Map<String, Long> pageInfo = new HashMap<String, Long>(); pageInfo.put("number", (long) page.getNumber()); pageInfo.put("size", (long) page.getSize() != 0 ? page.getSize() : page.getTotalElements()); if (totalElementsIsKnown) { pageInfo.put("totalPages", (long) page.getTotalPages()); pageInfo.put("totalElements", page.getTotalElements()); } return pageInfo; } EmbeddedPageHeader(UriComponentsBuilder self, Page page, boolean totalElementsIsKnown);  EmbeddedPageHeader(String self, Page page, boolean totalElementsIsKnown);  EmbeddedPageHeader(UriComponentsBuilder self, Page page); }
EmbeddedPageHeader { @JsonProperty(value = "page") public Map<String, Long> getPageInfo() { Map<String, Long> pageInfo = new HashMap<String, Long>(); pageInfo.put("number", (long) page.getNumber()); pageInfo.put("size", (long) page.getSize() != 0 ? page.getSize() : page.getTotalElements()); if (totalElementsIsKnown) { pageInfo.put("totalPages", (long) page.getTotalPages()); pageInfo.put("totalElements", page.getTotalElements()); } return pageInfo; } EmbeddedPageHeader(UriComponentsBuilder self, Page page, boolean totalElementsIsKnown);  EmbeddedPageHeader(String self, Page page, boolean totalElementsIsKnown);  EmbeddedPageHeader(UriComponentsBuilder self, Page page); @JsonProperty(value = "page") Map<String, Long> getPageInfo(); @JsonProperty(value = "_links") Map<String, Object> getLinks(); }
EmbeddedPageHeader { @JsonProperty(value = "page") public Map<String, Long> getPageInfo() { Map<String, Long> pageInfo = new HashMap<String, Long>(); pageInfo.put("number", (long) page.getNumber()); pageInfo.put("size", (long) page.getSize() != 0 ? page.getSize() : page.getTotalElements()); if (totalElementsIsKnown) { pageInfo.put("totalPages", (long) page.getTotalPages()); pageInfo.put("totalElements", page.getTotalElements()); } return pageInfo; } EmbeddedPageHeader(UriComponentsBuilder self, Page page, boolean totalElementsIsKnown);  EmbeddedPageHeader(String self, Page page, boolean totalElementsIsKnown);  EmbeddedPageHeader(UriComponentsBuilder self, Page page); @JsonProperty(value = "page") Map<String, Long> getPageInfo(); @JsonProperty(value = "_links") Map<String, Object> getLinks();  }