public class ControllerEntityLinks extends AbstractEntityLinks
EntityLinks implementation which assumes a certain URI mapping structure:
ExposesResourceFor annotation to declare that the annotated controller exposes collection
and item resources for.RequestMapping annotation to form the base URI of the collection resource.
@Controller
@ExposesResourceFor(Order.class)
@RequestMapping("/orders")
class OrderController {
@GetMapping
ResponseEntity orders(…) { … }
@GetMapping("/{id}")
ResponseEntity order(@PathVariable("id") … ) { … }
}
| Constructor and Description |
|---|
ControllerEntityLinks(Iterable<? extends Class<?>> controllerTypes,
LinkBuilderFactory<? extends LinkBuilder> linkBuilderFactory)
Creates a new
ControllerEntityLinks inspecting the configured classes for the given annotation. |
| Modifier and Type | Method and Description |
|---|---|
LinkBuilder |
linkFor(Class<?> entity)
Returns a
LinkBuilder able to create links to the controller managing the given entity type. |
LinkBuilder |
linkFor(Class<?> entity,
Object... parameters)
Returns a
LinkBuilder able to create links to the controller managing the given entity type, unfolding the
given parameters into the URI template the backing controller is mapped to. |
Link |
linkToCollectionResource(Class<?> entity)
Creates a
Link pointing to the collection resource of the given type. |
Link |
linkToItemResource(Class<?> entity,
Object id)
Creates a
Link pointing to item resource backing the given entity type and id. |
boolean |
supports(Class<?> delimiter) |
linkForItemResourceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforType, forType, linkForItemResource, linkToItemResourcepublic ControllerEntityLinks(Iterable<? extends Class<?>> controllerTypes, LinkBuilderFactory<? extends LinkBuilder> linkBuilderFactory)
ControllerEntityLinks inspecting the configured classes for the given annotation.controllerTypes - the controller classes to be inspected, must not be null.linkBuilderFactory - the LinkBuilder to use to create links, must not be null.public LinkBuilder linkFor(Class<?> entity)
EntityLinksLinkBuilder able to create links to the controller managing the given entity type. Expects a
controller being mapped to a fully expanded URI template (i.e. not path variables being used).entity - the entity type to point to, must not be null.LinkBuilder pointing to the collection resource. Will never be null.public LinkBuilder linkFor(Class<?> entity, Object... parameters)
EntityLinksLinkBuilder able to create links to the controller managing the given entity type, unfolding the
given parameters into the URI template the backing controller is mapped to.entity - the entity type to point to, must not be null.LinkBuilder pointing to the collection resource.public Link linkToCollectionResource(Class<?> entity)
EntityLinksLink pointing to the collection resource of the given type. The relation type of the link will be
determined by the implementation class and should be defaulted to IanaLinkRelations.SELF.entity - the entity type to point to, must not be null.Link pointing to the collection resource exposed for the given entity. Will never be
null.public Link linkToItemResource(Class<?> entity, Object id)
EntityLinksLink pointing to item resource backing the given entity type and id. The relation type of the
link will be determined by the implementation class and should be defaulted to IanaLinkRelations.SELF.entity - the entity type to point to, must not be null.id - the identifier of the entity of the given typeLink pointing to the resource exposed for the entity with the given type and id. Will never be
null.public boolean supports(Class<?> delimiter)
Copyright © 2011–2022 Pivotal, Inc.. All rights reserved.