Interface IConstraintValidationHandler

All Known Implementing Classes:
AbstractConstraintValidationHandler, FindingCollectingConstraintValidationHandler, LoggingConstraintValidationHandler

public interface IConstraintValidationHandler
Provides a set of callback methods used to process the result of evaluating a constraint.
  • Method Details

    • handleCardinalityMinimumViolation

      void handleCardinalityMinimumViolation(@NonNull ICardinalityConstraint constraint, @NonNull INodeItem target, @NonNull ISequence<? extends INodeItem> testedItems, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle a cardinality constraint minimum violation.
      Parameters:
      constraint - the constraint that was evaluated
      target - the node used as the evaluation focus to determine the items to test
      testedItems - the items tested
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleCardinalityMaximumViolation

      void handleCardinalityMaximumViolation(@NonNull ICardinalityConstraint constraint, @NonNull INodeItem target, @NonNull ISequence<? extends INodeItem> testedItems, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle a cardinality constraint maximum violation.
      Parameters:
      constraint - the constraint that was evaluated
      target - the node used as the evaluation focus to determine the items to test
      testedItems - the items tested
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleIndexDuplicateViolation

      void handleIndexDuplicateViolation(@NonNull IIndexConstraint constraint, @NonNull INodeItem node, @NonNull DynamicContext dynamicContext)
      Handle a duplicate index violation.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handleIndexDuplicateKeyViolation

      void handleIndexDuplicateKeyViolation(@NonNull IIndexConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem oldItem, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle an index duplicate key violation.

      This happens when two target nodes have the same key.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      oldItem - the node that exists in the index for the related key
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleUniqueKeyViolation

      void handleUniqueKeyViolation(@NonNull IUniqueConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem oldItem, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle an unique key violation.

      This happens when two target nodes have the same key.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      oldItem - the other node with the same key
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleKeyMatchError

      void handleKeyMatchError(@NonNull IKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull MetapathException exception, @NonNull DynamicContext dynamicContext)
      Handle an error that occurred while generating a key.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      exception - the resulting Metapath exception
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handleMissingIndexViolation

      void handleMissingIndexViolation(@NonNull IIndexHasKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String message, @NonNull DynamicContext dynamicContext)
      Handle a missing index violation.

      This happens when an index-has-key constraint references a missing index.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      message - the error message
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handleIndexMiss

      void handleIndexMiss(@NonNull IIndexHasKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull List<String> key, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle an index lookup key miss violation.

      This happens when another node references an expected member of an index that does not actually exist in the index.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      key - the key that was used to lookup the index entry
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleMatchPatternViolation

      void handleMatchPatternViolation(@NonNull IMatchesConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String value, @NonNull Pattern pattern, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle a match pattern violation.

      This happens when the target value does not match the specified pattern.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      value - the value used for pattern matching
      pattern - the pattern used for pattern matching
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleMatchDatatypeViolation

      void handleMatchDatatypeViolation(@NonNull IMatchesConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String value, @NonNull IDataTypeAdapter<?> adapter, @NonNull IllegalArgumentException cause, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle a match data type violation.

      This happens when the target value does not conform to the specified data type.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      value - the value used for data type matching
      adapter - the data type used for data type matching
      cause - the data type exception related to this violation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleExpectViolation

      void handleExpectViolation(@NonNull IExpectConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle an expect test violation.

      This happens when the test does not evaluate to true.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleReportViolation

      void handleReportViolation(@NonNull IReportConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Handle a report test finding.

      This happens when the report test expression evaluates to true. Unlike expect constraints which generate violations when false, report constraints generate findings when true.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleAllowedValuesViolation

      void handleAllowedValuesViolation(@NonNull List<IAllowedValuesConstraint> failedConstraints, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext)
      Handle an allowed values constraint violation.
      Parameters:
      failedConstraints - the allowed values constraints that did not match.
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handlePass

      void handlePass(@NonNull IConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext)
      Handle a constraint that has passed validation.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handleError

      void handleError(@NonNull IConstraint constraint, @NonNull INodeItem node, @NonNull String message, @NonNull Throwable exception, @NonNull DynamicContext dynamicContext)
      Handle a constraint that whose evaluation resulted in an unexpected error during validation.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      message - the error message
      exception - the causing exception
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation