Interface ObjectResolver

    • Method Detail

      • getName

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

        Map<String,​SerializablegetParameters()
        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