public class PagedResourcesAssembler<T> extends Object implements org.springframework.hateoas.server.RepresentationModelAssembler<Page<T>,org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<T>>>
| Constructor and Description |
|---|
PagedResourcesAssembler(HateoasPageableHandlerMethodArgumentResolver resolver,
UriComponents baseUri)
Creates a new
PagedResourcesAssembler using the given PageableHandlerMethodArgumentResolver and
base URI. |
| Modifier and Type | Method and Description |
|---|---|
protected <R extends org.springframework.hateoas.RepresentationModel<?>,S> |
createPagedModel(List<R> resources,
org.springframework.hateoas.PagedModel.PageMetadata metadata,
Page<S> page)
Creates the
PagedResources to be equipped with pagination links downstream. |
protected MethodParameter |
getMethodParameter()
Return the
MethodParameter to be used to potentially qualify the paging and sorting request parameters to. |
void |
setForceFirstAndLastRels(boolean forceFirstAndLastRels)
Configures whether to always add
first and last links to the PagedResources created. |
org.springframework.hateoas.PagedModel<?> |
toEmptyModel(Page<?> page,
Class<?> type)
Creates a
PagedResources with an empt collection EmbeddedWrapper for the given domain type. |
org.springframework.hateoas.PagedModel<?> |
toEmptyModel(Page<?> page,
Class<?> type,
org.springframework.hateoas.Link link)
Creates a
PagedResources with an empt collection EmbeddedWrapper for the given domain type. |
org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<T>> |
toModel(Page<T> entity) |
org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<T>> |
toModel(Page<T> page,
org.springframework.hateoas.Link selfLink)
Creates a new
PagedResources by converting the given Page into a PagedModel.PageMetadata instance and
wrapping the contained elements into Resource instances. |
<R extends org.springframework.hateoas.RepresentationModel<?>> |
toModel(Page<T> page,
org.springframework.hateoas.server.RepresentationModelAssembler<T,R> assembler)
|
<R extends org.springframework.hateoas.RepresentationModel<?>> |
toModel(Page<T> page,
org.springframework.hateoas.server.RepresentationModelAssembler<T,R> assembler,
org.springframework.hateoas.Link link)
|
public PagedResourcesAssembler(@Nullable HateoasPageableHandlerMethodArgumentResolver resolver, @Nullable UriComponents baseUri)
PagedResourcesAssembler using the given PageableHandlerMethodArgumentResolver and
base URI. If the former is null, a default one will be created. If the latter is null, calls
to toModel(Page) will use the current request's URI to build the relevant previous and next links.resolver - can be null.baseUri - can be null.public void setForceFirstAndLastRels(boolean forceFirstAndLastRels)
first and last links to the PagedResources created.
Defaults to false which means that first and last links only appear in conjunction with
prev and next links.forceFirstAndLastRels - whether to always add first and last links to the
PagedResources created.public org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<T>> toModel(Page<T> entity)
public org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<T>> toModel(Page<T> page, org.springframework.hateoas.Link selfLink)
PagedResources by converting the given Page into a PagedModel.PageMetadata instance and
wrapping the contained elements into Resource instances. Will add pagination links based on the given the
self link.page - must not be null.selfLink - must not be null.public <R extends org.springframework.hateoas.RepresentationModel<?>> org.springframework.hateoas.PagedModel<R> toModel(Page<T> page, org.springframework.hateoas.server.RepresentationModelAssembler<T,R> assembler)
PagedResources by converting the given Page into a PagedModel.PageMetadata instance and
using the given ResourceAssembler to turn elements of the Page into resources.page - must not be null.assembler - must not be null.public <R extends org.springframework.hateoas.RepresentationModel<?>> org.springframework.hateoas.PagedModel<R> toModel(Page<T> page, org.springframework.hateoas.server.RepresentationModelAssembler<T,R> assembler, org.springframework.hateoas.Link link)
PagedResources by converting the given Page into a PagedModel.PageMetadata instance and
using the given ResourceAssembler to turn elements of the Page into resources. Will add pagination
links based on the given the self link.page - must not be null.assembler - must not be null.link - must not be null.public org.springframework.hateoas.PagedModel<?> toEmptyModel(Page<?> page, Class<?> type)
PagedResources with an empt collection EmbeddedWrapper for the given domain type.page - must not be null, content must be empty.type - must not be null.public org.springframework.hateoas.PagedModel<?> toEmptyModel(Page<?> page, Class<?> type, org.springframework.hateoas.Link link)
PagedResources with an empt collection EmbeddedWrapper for the given domain type.page - must not be null, content must be empty.type - must not be null.link - must not be null.protected <R extends org.springframework.hateoas.RepresentationModel<?>,S> org.springframework.hateoas.PagedModel<R> createPagedModel(List<R> resources, org.springframework.hateoas.PagedModel.PageMetadata metadata, Page<S> page)
PagedResources to be equipped with pagination links downstream.resources - the original page's elements mapped into ResourceSupport instances.metadata - the calculated PagedModel.PageMetadata, must not be null.page - the original page handed to the assembler, must not be null.@Nullable protected MethodParameter getMethodParameter()
MethodParameter to be used to potentially qualify the paging and sorting request parameters to.
Default implementations returns null, which means the parameters will not be qualified.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.