Interface EntityLookup<T>

All Superinterfaces:
org.springframework.plugin.core.Plugin<Class<?>>
All Known Implementing Classes:
EntityLookupSupport

public interface EntityLookup<T> extends org.springframework.plugin.core.Plugin<Class<?>>
SPI to customize which property of an entity is used as unique identifier and how the entity instance is looked up from the backend. Prefer to extend EntityLookupSupport to let the generics declaration be used for the Plugin.supports(Object) method automatically.
Since:
2.5
Author:
Oliver Gierke
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the lookup property if available.
    Returns the property of the given entity that shall be used to uniquely identify it.
    Returns the entity instance to be used if an entity with the given identifier value is requested.

    Methods inherited from interface org.springframework.plugin.core.Plugin

    supports
  • Method Details

    • getResourceIdentifier

      Object getResourceIdentifier(T entity)
      Returns the property of the given entity that shall be used to uniquely identify it. If no EntityLookup is defined for a particular type, a standard identifier lookup mechanism (i.e. the datastore identifier) will be used to eventually create an identifying URI.
      Parameters:
      entity - will never be null.
      Returns:
      must not be null.
    • lookupEntity

      Optional<T> lookupEntity(Object id)
      Returns the entity instance to be used if an entity with the given identifier value is requested. Implementations will usually forward the call to a repository method explicitly and can assume the given value be basically the value they returned in getResourceIdentifier(Object).

      Implementations are free to return null to indicate absence of a value or wrap the result into any generally supported Optional type.

      Parameters:
      id - will never be null.
      Returns:
      can be null.
    • getLookupProperty

      Optional<String> getLookupProperty()
      Returns the lookup property if available. If Optional.empty() is returned, we assume the identifier property is the one to be used for lookup.
      Returns:
      will never be null.