Class DefaultSelfLinkProvider

java.lang.Object
org.springframework.data.rest.core.support.DefaultSelfLinkProvider
All Implemented Interfaces:
SelfLinkProvider

public class DefaultSelfLinkProvider extends Object implements SelfLinkProvider
Default implementation of SelfLinkProvider that uses an EntityLinks instance to create self links. Considers the configured EntityLookups to use the returned resource identifier to eventually create the link.
Since:
2.5
Author:
Oliver Gierke
  • Constructor Details

    • DefaultSelfLinkProvider

      public DefaultSelfLinkProvider(org.springframework.data.mapping.context.PersistentEntities entities, org.springframework.hateoas.server.EntityLinks entityLinks, List<? extends EntityLookup<?>> lookups, org.springframework.core.convert.ConversionService conversionService)
      Creates a new DefaultSelfLinkProvider from the PersistentEntities, EntityLinks and EntityLookups.
      Parameters:
      entities - must not be null.
      entityLinks - must not be null.
      lookups - must not be null.
  • Method Details

    • createSelfLinkFor

      public org.springframework.hateoas.Link createSelfLinkFor(Object instance)
      Description copied from interface: SelfLinkProvider
      Returns the self link for the given entity instance. Only call this with an actual entity instance. Otherwise, prefer SelfLinkProvider.createSelfLinkFor(Class, Object).
      Specified by:
      createSelfLinkFor in interface SelfLinkProvider
      Parameters:
      instance - must never be null.
      Returns:
      will never be null.
      See Also:
    • createSelfLinkFor

      public org.springframework.hateoas.Link createSelfLinkFor(Class<?> type, Object reference)
      Description copied from interface: SelfLinkProvider
      Returns the self link for the entity of the given type and the given reference. The latter can be an instance of the former, an identifier value of the former or anything that can be converted into an identifier in the first place.
      Specified by:
      createSelfLinkFor in interface SelfLinkProvider
      Parameters:
      type - must not be null.
      reference - must not be null.
      Returns:
      will never be null.