public abstract class RepresentationModelAssemblerSupport<T,D extends RepresentationModel<?>> extends Object implements RepresentationModelAssembler<T,D>
RepresentationModelAssembler
s. Will automate RepresentationModel
instance
creation and make sure a self-link is always added.Constructor and Description |
---|
RepresentationModelAssemblerSupport(Class<?> controllerClass,
Class<D> resourceType)
Creates a new
RepresentationModelAssemblerSupport using the given controller class and resource type. |
Modifier and Type | Method and Description |
---|---|
protected D |
createModelWithId(Object id,
T entity)
Creates a new resource with a self link to the given id.
|
protected D |
createModelWithId(Object id,
T entity,
Object... parameters) |
protected Class<?> |
getControllerClass() |
protected Class<D> |
getResourceType() |
protected D |
instantiateModel(T entity)
Instantiates the resource object.
|
org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport.Builder<T,D> |
map(Iterable<? extends T> entities)
Maps the given
Iterable of entities to either a CollectionModel or simple List of
RepresentationModel s. |
CollectionModel<D> |
toCollectionModel(Iterable<? extends T> entities)
Converts an
Iterable or T s into an Iterable of RepresentationModel and wraps them
in a CollectionModel instance. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toModel
public RepresentationModelAssemblerSupport(Class<?> controllerClass, Class<D> resourceType)
RepresentationModelAssemblerSupport
using the given controller class and resource type.controllerClass
- must not be null.resourceType
- must not be null.public CollectionModel<D> toCollectionModel(Iterable<? extends T> entities)
RepresentationModelAssembler
Iterable
or T
s into an Iterable
of RepresentationModel
and wraps them
in a CollectionModel
instance.toCollectionModel
in interface RepresentationModelAssembler<T,D extends RepresentationModel<?>>
entities
- must not be null.CollectionModel
containing D
.public org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport.Builder<T,D> map(Iterable<? extends T> entities)
Iterable
of entities to either a CollectionModel
or simple List of
RepresentationModel
s.entities
- must not be null.protected D createModelWithId(Object id, T entity)
entity
- must not be null.id
- must not be null.protected Class<?> getControllerClass()
protected D instantiateModel(T entity)
entity
- Copyright © 2011–2020 Pivotal, Inc.. All rights reserved.