Search in sources :

Example 1 with EmbeddedWrapper

use of org.springframework.hateoas.core.EmbeddedWrapper in project spring-data-commons by spring-projects.

the class PagedResourcesAssembler method toEmptyResource.

private PagedResources<?> toEmptyResource(Page<?> page, Class<?> type, Optional<Link> link) {
    Assert.notNull(page, "Page must must not be null!");
    Assert.isTrue(!page.hasContent(), "Page must not have any content!");
    Assert.notNull(type, "Type must not be null!");
    Assert.notNull(link, "Link must not be null!");
    PageMetadata metadata = asPageMetadata(page);
    EmbeddedWrapper wrapper = wrappers.emptyCollectionOf(type);
    List<EmbeddedWrapper> embedded = Collections.singletonList(wrapper);
    return addPaginationLinks(new PagedResources<>(embedded, metadata), page, link);
}
Also used : PageMetadata(org.springframework.hateoas.PagedResources.PageMetadata) EmbeddedWrapper(org.springframework.hateoas.core.EmbeddedWrapper)

Aggregations

PageMetadata (org.springframework.hateoas.PagedResources.PageMetadata)1 EmbeddedWrapper (org.springframework.hateoas.core.EmbeddedWrapper)1