Class InferredAttributeChangeValidator

java.lang.Object
cz.cvut.kbss.jopa.sessions.validator.InferredAttributeChangeValidator

public class InferredAttributeChangeValidator extends Object
Verifies whether a change to an inferred attribute is valid.

Changes to attributes possibly containing inferred values have to be validated before merging into storage. This is because if the value is inferred, it cannot be directly removed from the repository, as it is deduced from other statements. Therefore, this validator checks for value removals (update to a singular attribute is a sequence of remove and add in this context) and verifies that none of the removed statements are inferred in the storage. If they are, a InferredAttributeModifiedException is thrown.

  • Constructor Details

    • InferredAttributeChangeValidator

      public InferredAttributeChangeValidator(ConnectionWrapper connectionWrapper)
  • Method Details

    • validateChange

      public <T> void validateChange(T instance, T original, FieldSpecification<? super T,?> fieldSpec, Descriptor instanceDescriptor)
      Checks whether the changes to the specified attribute on the specified instance are valid w.r.t. inference in the repository.
      Type Parameters:
      T - Instance type
      Parameters:
      instance - The changed instance
      original - Object containing original values
      fieldSpec - Specification of the modified field
      instanceDescriptor - Instance descriptor for repository context resolution
    • isInferredValueRemoval

      public <T> boolean isInferredValueRemoval(T instance, T original, FieldSpecification<? super T,?> fieldSpec, Descriptor instanceDescriptor)
      Checks whether a change to the specified attribute on the specified instance involves removal of an inferred value.

      Removal of inferred values is generally not possible and should lead to an exception or another predictable reject of such a change.

      Type Parameters:
      T - Instance type
      Parameters:
      instance - The changed instance
      original - Object containing original values
      fieldSpec - Specification of the modified field
      instanceDescriptor - Instance descriptor for repository context resolution
      Returns:
      true when changed instance removes inferred value from the specified attribute, false otherwise