Interface ObjectResolver

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractObjectResolver, DirectoryEntryResolver, DocumentModelResolver, TestingColorResolver, UserManagerResolver

public interface ObjectResolver extends Serializable
External references are document field with a simple type whose value refers to an external business entity. Objects implementing this interface are able to resolve the entity using the reference.
Since:
7.1
  • Field Details

    • VALIDATION_PARAMETER_KEY

      static final String VALIDATION_PARAMETER_KEY
      The validation parameter key to enable/disable validation on resolver. Enabled by default.
      Since:
      10.2
      See Also:
  • Method Details

    • configure

      void configure(Map<String,String> parameters) throws IllegalArgumentException, IllegalStateException
      Configure this resolver.
      Parameters:
      parameters - A map of parameter whose keys are parameter names and map value are corresponding values.
      Throws:
      IllegalArgumentException - If some parameter are not compatible with this resolver.
      IllegalStateException - If this resolver is already configured.
      Since:
      7.1
    • getManagedClasses

      List<Class<?>> getManagedClasses()
      Returns the resolved object types.
      Since:
      7.2
    • getName

      String getName()
      Provides this resolver name.
      Returns:
      The resolver name.
      Since:
      7.1
    • getParameters

      Map<String,Serializable> getParameters()
      Provides this resolver parameters.
      Returns:
      A map containing associating parameter name to its value
      Since:
      7.1
    • validate

      boolean validate(Object value)
      Validates some value references an existing entity.
      Parameters:
      value - The reference.
      Returns:
      true if value could be resolved as an existing external reference, false otherwise.
      Throws:
      IllegalStateException - If this resolver has not been configured.
      Since:
      7.1
    • validate

      default boolean validate(Object value, Object context)
      Validates some value references an existing entity, in the given context
      Parameters:
      value - The reference.
      context - A resolver-specific context allowing resolution of the value.
      Returns:
      true if value could be resolved as an existing external reference, false otherwise.
      Throws:
      IllegalStateException - If this resolver has not been configured.
      Since:
      10.2
    • fetch

      Object fetch(Object value)
      Provides the entity referenced by a value.
      Parameters:
      value - The reference.
      Returns:
      The referenced entity, null if no entity matches the value.
      Throws:
      IllegalStateException - If this resolver has not been configured.
      Since:
      7.1
    • fetch

      default Object fetch(Object value, Object context)
      Provides the entity referenced by a value, in the given context.
      Parameters:
      value - The reference.
      context - A resolver-specific context allowing resolution of the value.
      Returns:
      The referenced entity, null if no entity matches the value.
      Throws:
      IllegalStateException - If this resolver has not been configured.
      Since:
      10.2
    • fetch

      <T> T fetch(Class<T> type, Object value)
      Provides the entity referenced by a value, return the entity as expected type.
      Parameters:
      value - The reference.
      Returns:
      The referenced entity, null if no entity matches the value or if this entity cannot be converted as type.
      Throws:
      IllegalStateException - If this resolver has not been configured.
      Since:
      7.1
    • getReference

      Serializable getReference(Object object)
      Generates a reference to an entity.
      Parameters:
      object - The entity.
      Returns:
      A reference to the entity or null if its not a managed entity type.
      Throws:
      IllegalStateException - If this resolver has not been configured.
      Since:
      7.1
    • getConstraintErrorMessage

      String getConstraintErrorMessage(Object invalidValue, Locale locale)
      Provides an error message to display when some invalid value does not match existing entity.
      Parameters:
      invalidValue - The invalid value that don't match any entity.
      locale - The language in which the message should be generated.
      Returns:
      A message in the specified language or
      Since:
      7.1