Module dev.metaschema.core
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 Summary
Modifier and TypeMethodDescriptionvoidhandleAllowedValuesViolation(List<IAllowedValuesConstraint> failedConstraints, INodeItem target, DynamicContext dynamicContext) Handle an allowed values constraint violation.voidhandleCardinalityMaximumViolation(ICardinalityConstraint constraint, INodeItem target, ISequence<? extends INodeItem> testedItems, DynamicContext dynamicContext) Handle a cardinality constraint maximum violation.voidhandleCardinalityMinimumViolation(ICardinalityConstraint constraint, INodeItem target, ISequence<? extends INodeItem> testedItems, DynamicContext dynamicContext) Handle a cardinality constraint minimum violation.voidhandleError(IConstraint constraint, INodeItem node, String message, Throwable exception, DynamicContext dynamicContext) Handle a constraint that whose evaluation resulted in an unexpected error during validation.voidhandleExpectViolation(IExpectConstraint constraint, INodeItem node, INodeItem target, DynamicContext dynamicContext) Handle an expect test violation.voidhandleIndexDuplicateKeyViolation(IIndexConstraint constraint, INodeItem node, INodeItem oldItem, INodeItem target, DynamicContext dynamicContext) Handle an index duplicate key violation.voidhandleIndexDuplicateViolation(IIndexConstraint constraint, INodeItem node, DynamicContext dynamicContext) Handle a duplicate index violation.voidhandleIndexMiss(IIndexHasKeyConstraint constraint, INodeItem node, INodeItem target, List<String> key, DynamicContext dynamicContext) Handle an index lookup key miss violation.voidhandleKeyMatchError(IKeyConstraint constraint, INodeItem node, INodeItem target, MetapathException exception, DynamicContext dynamicContext) Handle an error that occurred while generating a key.voidhandleMatchDatatypeViolation(IMatchesConstraint constraint, INodeItem node, INodeItem target, String value, IDataTypeAdapter<?> adapter, IllegalArgumentException cause, DynamicContext dynamicContext) Handle a match data type violation.voidhandleMatchPatternViolation(IMatchesConstraint constraint, INodeItem node, INodeItem target, String value, Pattern pattern, DynamicContext dynamicContext) Handle a match pattern violation.voidhandleMissingIndexViolation(IIndexHasKeyConstraint constraint, INodeItem node, INodeItem target, String message, DynamicContext dynamicContext) Handle a missing index violation.voidhandlePass(IConstraint constraint, INodeItem node, INodeItem target, DynamicContext dynamicContext) Handle a constraint that has passed validation.voidhandleReportViolation(IReportConstraint constraint, INodeItem node, INodeItem target, DynamicContext dynamicContext) Handle a report test finding.voidhandleUniqueKeyViolation(IUniqueConstraint constraint, INodeItem node, INodeItem oldItem, INodeItem target, DynamicContext dynamicContext) Handle an unique key violation.
-
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 evaluatedtarget- the node used as the evaluation focus to determine the items to testtestedItems- the items testeddynamicContext- 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 evaluatedtarget- the node used as the evaluation focus to determine the items to testtestedItems- the items testeddynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetsdynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetsoldItem- the node that exists in the index for the related keytarget- the target of evaluationdynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetsoldItem- the other node with the same keytarget- the target of evaluationdynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationexception- the resulting Metapath exceptiondynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationmessage- the error messagedynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationkey- the key that was used to lookup the index entrydynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationvalue- the value used for pattern matchingpattern- the pattern used for pattern matchingdynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationvalue- the value used for data type matchingadapter- the data type used for data type matchingcause- the data type exception related to this violationdynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationdynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationdynamicContext- 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 evaluationdynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationdynamicContext- 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 evaluatednode- the node used as the evaluation focus to determine constraint targetsmessage- the error messageexception- the causing exceptiondynamicContext- the Metapath dynamic execution context to use for Metapath evaluation
-