Class ControllerEntityLinks
java.lang.Object
org.springframework.hateoas.server.core.AbstractEntityLinks
org.springframework.hateoas.server.core.ControllerEntityLinks
- All Implemented Interfaces:
EntityLinks
,org.springframework.plugin.core.Plugin<Class<?>>
EntityLinks
implementation which assumes a certain URI mapping structure:
- A class-level
ExposesResourceFor
annotation to declare that the annotated controller exposes collection and item resources for. - An
RequestMapping
annotation to form the base URI of the collection resource. - A controller method with a mapping annotation to actually handle at least one HTTP method.
- A controller method that maps a subordinate resource taking a path variable to identify an item resource.
@Controller @ExposesResourceFor(Order.class) @RequestMapping("/orders") class OrderController { @GetMapping ResponseEntity orders(…) { … } @GetMapping("/{id}") ResponseEntity order(@PathVariable("id") … ) { … } }
- Author:
- Oliver Gierke
-
Constructor Summary
ConstructorDescriptionControllerEntityLinks
(Iterable<? extends Class<?>> controllerTypes, LinkBuilderFactory<? extends LinkBuilder> linkBuilderFactory) Creates a newControllerEntityLinks
inspecting the configured classes for the given annotation. -
Method Summary
Modifier and TypeMethodDescriptionReturns aLinkBuilder
able to create links to the controller managing the given entity type.Returns aLinkBuilder
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.linkToCollectionResource
(Class<?> entity) Creates aLink
pointing to the collection resource of the given type.linkToItemResource
(Class<?> entity, Object id) Creates aLink
pointing to item resource backing the given entity type and id.boolean
Methods inherited from class org.springframework.hateoas.server.core.AbstractEntityLinks
linkForItemResource
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.hateoas.server.EntityLinks
forType, forType, linkForItemResource, linkToItemResource
-
Constructor Details
-
ControllerEntityLinks
public ControllerEntityLinks(Iterable<? extends Class<?>> controllerTypes, LinkBuilderFactory<? extends LinkBuilder> linkBuilderFactory) Creates a newControllerEntityLinks
inspecting the configured classes for the given annotation.- Parameters:
controllerTypes
- the controller classes to be inspected, must not be null.linkBuilderFactory
- theLinkBuilder
to use to create links, must not be null.
-
-
Method Details
-
linkFor
Description copied from interface:EntityLinks
Returns aLinkBuilder
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).- Parameters:
entity
- the entity type to point to, must not be null.- Returns:
- the
LinkBuilder
pointing to the collection resource. Will never be null.
-
linkFor
Description copied from interface:EntityLinks
Returns aLinkBuilder
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.- Parameters:
entity
- the entity type to point to, must not be null.- Returns:
- the
LinkBuilder
pointing to the collection resource.
-
linkToCollectionResource
Description copied from interface:EntityLinks
Creates aLink
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 toIanaLinkRelations.SELF
.- Parameters:
entity
- the entity type to point to, must not be null.- Returns:
- the
Link
pointing to the collection resource exposed for the given entity. Will never be null.
-
linkToItemResource
Description copied from interface:EntityLinks
Creates aLink
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 toIanaLinkRelations.SELF
.- Parameters:
entity
- the entity type to point to, must not be null.id
- the identifier of the entity of the given type- Returns:
- the
Link
pointing to the resource exposed for the entity with the given type and id. Will never be null.
-
supports
-