Interface EntityLinks

All Superinterfaces:
org.springframework.plugin.core.Plugin<Class<?>>
All Known Implementing Classes:
AbstractEntityLinks, ControllerEntityLinks, DelegatingEntityLinks

public interface EntityLinks extends org.springframework.plugin.core.Plugin<Class<?>>
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 Details

    • linkFor

      LinkBuilder linkFor(Class<?> type)
      Returns a LinkBuilder 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

      LinkBuilder linkFor(Class<?> type, 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.
      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

      LinkBuilder linkForItemResource(Class<?> type, Object id)
      Returns a LinkBuilder 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

      default <T> LinkBuilder linkForItemResource(T entity, Function<T,Object> identifierExtractor)
      Returns a LinkBuilder 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

      Link linkToCollectionResource(Class<?> type)
      Creates a Link 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.
      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

      Link linkToItemResource(Class<?> type, Object id)
      Creates a Link 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.
      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

      default <T> Link linkToItemResource(T entity, Function<T,Object> identifierExtractor)
      Creates a Link 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 to IanaLinkRelations.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

      default <T> TypedEntityLinks<T> forType(Function<T,?> extractor)
      Creates a TypedEntityLinks 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 a TypedEntityLinks 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: