Interface EntityLinks
- All Superinterfaces:
org.springframework.plugin.core.Plugin<Class<?>>
- All Known Implementing Classes:
AbstractEntityLinks
,ControllerEntityLinks
,DelegatingEntityLinks
Accessor to links pointing to controllers backing an entity type. The
IllegalArgumentException
potentially
thrown by the declared methods will only appear if the Plugin#supports(Class)
method has returned
false and the method has been invoked anyway, i.e. if Plugin#supports(Class)
returns
true it's safe to invoke the interface methods and the exception will never be thrown.- Author:
- Oliver Gierke
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> TypedEntityLinks.ExtendedTypedEntityLinks<T>
Creates aTypedEntityLinks
instance using the given type and identifier extractor function.default <T> TypedEntityLinks<T>
Creates aTypedEntityLinks
instance using the given identifier extractor function.Returns 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.linkForItemResource
(Class<?> type, Object id) Returns aLinkBuilder
able to create links to the controller managing the given entity type and id.default <T> LinkBuilder
linkForItemResource
(T entity, Function<T, Object> identifierExtractor) Returns aLinkBuilder
able to create links to the controller managing the given entity type and identifier extractor.linkToCollectionResource
(Class<?> type) Creates aLink
pointing to the collection resource of the given type.linkToItemResource
(Class<?> type, Object id) Creates aLink
pointing to item resource backing the given entity type and id.default <T> Link
linkToItemResource
(T entity, Function<T, Object> identifierExtractor) Creates aLink
pointing to item resource backing the given entity and identifier extractor.Methods inherited from interface org.springframework.plugin.core.Plugin
supports
-
Method Details
-
linkFor
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:
type
- the entity type to point to, must not be null.- Returns:
- the
LinkBuilder
pointing to the collection resource. Will never be null. - Throws:
IllegalArgumentException
- in case the given type is unknown the entity links infrastructure.
-
linkFor
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:
type
- the entity type to point to, must not be null.- Returns:
- the
LinkBuilder
pointing to the collection resource. - Throws:
IllegalArgumentException
- in case the given type is unknown the entity links infrastructure.
-
linkForItemResource
Returns aLinkBuilder
able to create links to the controller managing the given entity type and id. Implementations will know about the URI structure being used to expose item-resource URIs.- Parameters:
type
- the entity type to point to, must not be null.id
- the id of the object of the handed type, must not be null.- Returns:
- the
LinkBuilder
pointing to the item resource identified by the given type and id. Will never be null. - Throws:
IllegalArgumentException
- in case the given type is unknown the entity links infrastructure.
-
linkForItemResource
Returns aLinkBuilder
able to create links to the controller managing the given entity type and identifier extractor. Implementations will know about the URI structure being used to expose item-resource URIs.- Parameters:
entity
- the entity to point to, must not be null.identifierExtractor
- an extractor function to determine the id of the given entity, must not be null.- Returns:
- the
LinkBuilder
pointing to the item resource identified by the given entity. Will never be null. - Throws:
IllegalArgumentException
- in case the given type is unknown the entity links infrastructure.
-
linkToCollectionResource
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:
type
- 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. - Throws:
IllegalArgumentException
- in case the given type is unknown the entity links infrastructure.
-
linkToItemResource
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:
type
- 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. - Throws:
IllegalArgumentException
- in case the given type is unknown the entity links infrastructure.
-
linkToItemResource
Creates aLink
pointing to item resource backing the given entity and identifier extractor. The relation type of the link will be determined by the implementation class and should be defaulted toIanaLinkRelations.SELF
.- Parameters:
entity
- the entity to point to, must not be null.identifierExtractor
- an extractor function to determine the id of the given entity.- Returns:
- the
Link
pointing to the resource exposed for the given entity. Will never be null. - Throws:
IllegalArgumentException
- in case the given type is unknown the entity links infrastructure.
-
forType
Creates aTypedEntityLinks
instance using the given identifier extractor function.- Type Parameters:
T
- the type of entity to be handled.- Parameters:
extractor
- the extractor to use to derive an identifier from the given entity.- Returns:
-
forType
default <T> TypedEntityLinks.ExtendedTypedEntityLinks<T> forType(Class<T> type, Function<T, Object> extractor) Creates aTypedEntityLinks
instance using the given type and identifier extractor function.- Type Parameters:
T
- the type of entity to be handled.- Parameters:
type
- the type of entity.extractor
- the extractor to use to derive an identifier from the given entity.- Returns:
-