Class FindingCollectingConstraintValidationHandler
- All Implemented Interfaces:
IConstraintValidationHandler,IValidationResult
getFindings() method.
This class is thread-safe and can be used with parallel constraint validation.
-
Field Summary
Fields inherited from interface dev.metaschema.core.model.validation.IValidationResult
PASSING_RESULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddFinding(ConstraintValidationFinding finding) Add a finding to the collection of findings maintained by this instance.Get the list of validation findings, which may be empty.Get the highest finding severity level for the validation.voidhandleAllowedValuesViolation(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 cause, 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.Methods inherited from class dev.metaschema.core.model.constraint.AbstractConstraintValidationHandler
getPathFormatter, newAllowedValuesViolationMessage, newCardinalityMaximumViolationMessage, newCardinalityMinimumViolationMessage, newExpectViolationMessage, newIndexDuplicateKeyViolationMessage, newIndexDuplicateViolationMessage, newIndexMissMessage, newMatchDatatypeViolationMessage, newMatchPatternViolationMessage, newMissingIndexViolationMessage, newReportViolationMessage, newUniqueKeyViolationMessage, setPathFormatter, toPathMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.metaschema.core.model.validation.IValidationResult
isPassing
-
Constructor Details
-
FindingCollectingConstraintValidationHandler
public FindingCollectingConstraintValidationHandler()
-
-
Method Details
-
getFindings
Description copied from interface:IValidationResultGet the list of validation findings, which may be empty.- Specified by:
getFindingsin interfaceIValidationResult- Returns:
- the list
-
getHighestSeverity
Description copied from interface:IValidationResultGet the highest finding severity level for the validation. The levelIConstraint.Level.INFORMATIONALwill be returned if no validation findings were identified.- Specified by:
getHighestSeverityin interfaceIValidationResult- Returns:
- the highest finding severity level
-
addFinding
Add a finding to the collection of findings maintained by this instance.- Parameters:
finding- the finding to add
-
handleCardinalityMinimumViolation
public void handleCardinalityMinimumViolation(@NonNull ICardinalityConstraint constraint, @NonNull INodeItem target, @NonNull ISequence<? extends INodeItem> testedItems, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Description copied from interface:IConstraintValidationHandlerHandle a cardinality constraint minimum violation.- Specified by:
handleCardinalityMinimumViolationin interfaceIConstraintValidationHandler- 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
public void handleCardinalityMaximumViolation(@NonNull ICardinalityConstraint constraint, @NonNull INodeItem target, @NonNull ISequence<? extends INodeItem> testedItems, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Description copied from interface:IConstraintValidationHandlerHandle a cardinality constraint maximum violation.- Specified by:
handleCardinalityMaximumViolationin interfaceIConstraintValidationHandler- 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
-
handleIndexDuplicateKeyViolation
public void handleIndexDuplicateKeyViolation(@NonNull IIndexConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem oldItem, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Description copied from interface:IConstraintValidationHandlerHandle an index duplicate key violation.This happens when two target nodes have the same key.
- Specified by:
handleIndexDuplicateKeyViolationin interfaceIConstraintValidationHandler- 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
public void handleUniqueKeyViolation(@NonNull IUniqueConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem oldItem, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Description copied from interface:IConstraintValidationHandlerHandle an unique key violation.This happens when two target nodes have the same key.
- Specified by:
handleUniqueKeyViolationin interfaceIConstraintValidationHandler- 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
public void handleKeyMatchError(@NonNull IKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull MetapathException cause, @NonNull DynamicContext dynamicContext) Description copied from interface:IConstraintValidationHandlerHandle an error that occurred while generating a key.- Specified by:
handleKeyMatchErrorin interfaceIConstraintValidationHandler- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationcause- the resulting Metapath exceptiondynamicContext- the Metapath dynamic execution context to use for Metapath evaluation
-
handleMatchPatternViolation
public void handleMatchPatternViolation(@NonNull IMatchesConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String value, @NonNull Pattern pattern, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Description copied from interface:IConstraintValidationHandlerHandle a match pattern violation.This happens when the target value does not match the specified pattern.
- Specified by:
handleMatchPatternViolationin interfaceIConstraintValidationHandler- 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
public 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 Description copied from interface:IConstraintValidationHandlerHandle a match data type violation.This happens when the target value does not conform to the specified data type.
- Specified by:
handleMatchDatatypeViolationin interfaceIConstraintValidationHandler- 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
public void handleExpectViolation(@NonNull IExpectConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Description copied from interface:IConstraintValidationHandlerHandle an expect test violation.This happens when the test does not evaluate to true.
- Specified by:
handleExpectViolationin interfaceIConstraintValidationHandler- 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
public void handleReportViolation(@NonNull IReportConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Description copied from interface:IConstraintValidationHandlerHandle 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.
- Specified by:
handleReportViolationin interfaceIConstraintValidationHandler- 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
public void handleAllowedValuesViolation(@NonNull List<IAllowedValuesConstraint> failedConstraints, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) Description copied from interface:IConstraintValidationHandlerHandle an allowed values constraint violation.- Specified by:
handleAllowedValuesViolationin interfaceIConstraintValidationHandler- 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
-
handleIndexDuplicateViolation
public void handleIndexDuplicateViolation(IIndexConstraint constraint, INodeItem node, @NonNull DynamicContext dynamicContext) Description copied from interface:IConstraintValidationHandlerHandle a duplicate index violation.- Specified by:
handleIndexDuplicateViolationin interfaceIConstraintValidationHandler- 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
-
handleIndexMiss
public void handleIndexMiss(@NonNull IIndexHasKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull List<String> key, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Description copied from interface:IConstraintValidationHandlerHandle 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.
- Specified by:
handleIndexMissin interfaceIConstraintValidationHandler- 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
-
handleMissingIndexViolation
public void handleMissingIndexViolation(@NonNull IIndexHasKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String message, @NonNull DynamicContext dynamicContext) Description copied from interface:IConstraintValidationHandlerHandle a missing index violation.This happens when an index-has-key constraint references a missing index.
- Specified by:
handleMissingIndexViolationin interfaceIConstraintValidationHandler- 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
-
handlePass
public void handlePass(@NonNull IConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) Description copied from interface:IConstraintValidationHandlerHandle a constraint that has passed validation.- Specified by:
handlePassin interfaceIConstraintValidationHandler- 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
public void handleError(@NonNull IConstraint constraint, @NonNull INodeItem node, @NonNull String message, @NonNull Throwable exception, @NonNull DynamicContext dynamicContext) Description copied from interface:IConstraintValidationHandlerHandle a constraint that whose evaluation resulted in an unexpected error during validation.- Specified by:
handleErrorin interfaceIConstraintValidationHandler- 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
-