Package org.springframework.data.web
Class SlicedResourcesAssembler<T>
java.lang.Object
org.springframework.data.web.SlicedResourcesAssembler<T>
- All Implemented Interfaces:
- RepresentationModelAssembler<Slice<T>,- SlicedModel<EntityModel<T>>> 
public class SlicedResourcesAssembler<T>
extends Object
implements RepresentationModelAssembler<Slice<T>,SlicedModel<EntityModel<T>>> 
- Since:
- 3.1
- Author:
- Michael Schout, Oliver Drotbohm
- 
Constructor SummaryConstructorsConstructorDescriptionSlicedResourcesAssembler(HateoasPageableHandlerMethodArgumentResolver resolver, UriComponents baseUri) Creates a newSlicedResourcesAssemblerusing the givenPageableHandlerMethodArgumentResolverand base URI.
- 
Method SummaryModifier and TypeMethodDescriptionprotected <R extends RepresentationModel<?>,S> 
 SlicedModel<R>createSlicedModel(List<R> resources, SlicedModel.SliceMetadata metadata, Slice<S> slice) Creates theSlicedModelto be equipped with pagination links downstream.voidsetForceFirstRel(boolean forceFirstRel) Configures whether to always addfirstlinks to theSlicedModel* created.SlicedModel<?>toEmptyModel(Slice<?> slice, Class<?> type) Creates aSlicedModelwith an empty collectionEmbeddedWrapperfor the given domain type.SlicedModel<?>toEmptyModel(Slice<?> slice, Class<?> type, Optional<Link> link) SlicedModel<?>toEmptyModel(Slice<?> slice, Class<?> type, Link link) Creates aSlicedModelwith an empty collectionEmbeddedWrapperfor the given domain type.Creates a newSlicedModelby converting the givenSliceinto aSlicedModel.SliceMetadatainstance and wrapping the contained elements into *SlicedModelinstances.<R extends RepresentationModel<?>>
 SlicedModel<R>toModel(Slice<T> slice, RepresentationModelAssembler<T, R> assembler) Creates a newSlicedModelby converting the givenSliceinto aSlicedModel.SliceMetadatainstance and using the givenSlicedModelto turn elements of theSliceinto resources.<R extends RepresentationModel<?>>
 SlicedModel<R>Creates a newSlicedModelby converting the givenSliceinto aSlicedModel.SliceMetadatainstance and using the givenSlicedModelto turn elements of theSliceinto resources.withParameter(MethodParameter parameter) Creates a newSlicedResourcesAssemblerwith the given referenceMethodParameter.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.hateoas.server.RepresentationModelAssemblertoCollectionModel
- 
Constructor Details- 
SlicedResourcesAssemblerpublic SlicedResourcesAssembler(@Nullable HateoasPageableHandlerMethodArgumentResolver resolver, @Nullable UriComponents baseUri) Creates a newSlicedResourcesAssemblerusing the givenPageableHandlerMethodArgumentResolverand base URI. If the former is null, a default one will be created. If the latter is null, calls totoModel(Slice)will use the current request's URI to build the relevant previous and next links.- Parameters:
- resolver- can be null.
- baseUri- can be null.
 
 
- 
- 
Method Details- 
setForceFirstRelpublic void setForceFirstRel(boolean forceFirstRel) Configures whether to always addfirstlinks to theSlicedModel* created. Defaults to false which means thatfirstlinks onlys appear in conjunction withprevandnextlinks.- Parameters:
- forceFirstRel- whether to always add- firstlinks to the- SlicedModelcreated.
 
- 
withParameterCreates a newSlicedResourcesAssemblerwith the given referenceMethodParameter.- Parameters:
- parameter- can be null.
- Returns:
- will never be null.
- Since:
- 3.1
 
- 
toModel- Specified by:
- toModelin interface- RepresentationModelAssembler<Slice<T>,- SlicedModel<EntityModel<T>>> 
 
- 
toModelCreates a newSlicedModelby converting the givenSliceinto aSlicedModel.SliceMetadatainstance and wrapping the contained elements into *SlicedModelinstances. Will add pagination links based on the given self link.- Parameters:
- slice- must not be null.
- selfLink- must not be null.
- Returns:
 
- 
toModelpublic <R extends RepresentationModel<?>> SlicedModel<R> toModel(Slice<T> slice, RepresentationModelAssembler<T, R> assembler) Creates a newSlicedModelby converting the givenSliceinto aSlicedModel.SliceMetadatainstance and using the givenSlicedModelto turn elements of theSliceinto resources.- Parameters:
- slice- must not be null.
- assembler- must not be null.
- Returns:
 
- 
toModelpublic <R extends RepresentationModel<?>> SlicedModel<R> toModel(Slice<T> slice, RepresentationModelAssembler<T, R> assembler, Link link) Creates a newSlicedModelby converting the givenSliceinto aSlicedModel.SliceMetadatainstance and using the givenSlicedModelto turn elements of theSliceinto resources. Will add pagination links based on the given the self link.- Parameters:
- slice- must not be null.
- assembler- must not be null.
- link- must not be null.
- Returns:
 
- 
toEmptyModelCreates aSlicedModelwith an empty collectionEmbeddedWrapperfor the given domain type.- Parameters:
- slice- must not be null, content must be empty.
- type- must not be null.
- Returns:
 
- 
toEmptyModelCreates aSlicedModelwith an empty collectionEmbeddedWrapperfor the given domain type.- Parameters:
- slice- must not be null, content must be empty.
- type- must not be null.
- link- must not be null.
- Returns:
 
- 
toEmptyModel
- 
createSlicedModelprotected <R extends RepresentationModel<?>,S> SlicedModel<R> createSlicedModel(List<R> resources, SlicedModel.SliceMetadata metadata, Slice<S> slice) Creates theSlicedModelto be equipped with pagination links downstream.- Parameters:
- resources- the original slices's elements mapped into- RepresentationModelinstances.
- metadata- the calculated- SlicedModel.SliceMetadata, must not be null.
- slice- the original page handed to the assembler, must not be null.
- Returns:
- must not be null.
 
 
-