Module dev.metaschema.core
Class AbstractConstraintValidationHandler
java.lang.Object
dev.metaschema.core.model.constraint.AbstractConstraintValidationHandler
- All Implemented Interfaces:
IConstraintValidationHandler
- Direct Known Subclasses:
FindingCollectingConstraintValidationHandler,LoggingConstraintValidationHandler
public abstract class AbstractConstraintValidationHandler
extends Object
implements IConstraintValidationHandler
Provides messaging for constraint violations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the formatter used to generate content paths for validation issue locations.protected StringnewAllowedValuesViolationMessage(List<IAllowedValuesConstraint> constraints, INodeItem target) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewCardinalityMaximumViolationMessage(ICardinalityConstraint constraint, INodeItem target, ISequence<? extends INodeItem> testedItems, DynamicContext dynamicContext) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewCardinalityMinimumViolationMessage(ICardinalityConstraint constraint, INodeItem target, ISequence<? extends INodeItem> testedItems, DynamicContext dynamicContext) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewExpectViolationMessage(IExpectConstraint constraint, INodeItem node, INodeItem target, DynamicContext dynamicContext) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewIndexDuplicateKeyViolationMessage(IIndexConstraint constraint, INodeItem node, INodeItem oldItem, INodeItem target, DynamicContext dynamicContext) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewIndexDuplicateViolationMessage(IIndexConstraint constraint, INodeItem node) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewIndexMissMessage(IIndexHasKeyConstraint constraint, INodeItem node, INodeItem target, List<String> key, DynamicContext dynamicContext) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewMatchDatatypeViolationMessage(IMatchesConstraint constraint, INodeItem node, INodeItem target, String value, IDataTypeAdapter<?> adapter, DynamicContext dynamicContext) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewMatchPatternViolationMessage(IMatchesConstraint constraint, INodeItem node, INodeItem target, String value, Pattern pattern, DynamicContext dynamicContext) Construct a new violation message for the providedconstraintapplied to thenode.protected StringnewMissingIndexViolationMessage(IIndexHasKeyConstraint constraint, INodeItem node, INodeItem target, String message, DynamicContext dynamicContext) Construct a new generic violation message for the providedconstraintapplied to thenode.protected StringnewReportViolationMessage(IReportConstraint constraint, INodeItem node, INodeItem target, DynamicContext dynamicContext) Construct a new message for the provided reportconstraintapplied to thenode.protected StringnewUniqueKeyViolationMessage(IUniqueConstraint constraint, INodeItem node, INodeItem oldItem, INodeItem target, DynamicContext dynamicContext) Construct a new violation message for the providedconstraintapplied to thenode.voidsetPathFormatter(IPathFormatter formatter) Set the path formatter to use when generating contextual paths in validation messages.protected StringGet the path of the provided item using the configured path formatter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.metaschema.core.model.constraint.IConstraintValidationHandler
handleAllowedValuesViolation, handleCardinalityMaximumViolation, handleCardinalityMinimumViolation, handleError, handleExpectViolation, handleIndexDuplicateKeyViolation, handleIndexDuplicateViolation, handleIndexMiss, handleKeyMatchError, handleMatchDatatypeViolation, handleMatchPatternViolation, handleMissingIndexViolation, handlePass, handleReportViolation, handleUniqueKeyViolation
-
Constructor Details
-
AbstractConstraintValidationHandler
public AbstractConstraintValidationHandler()
-
-
Method Details
-
getPathFormatter
Get the formatter used to generate content paths for validation issue locations.- Returns:
- the formatter
-
setPathFormatter
Set the path formatter to use when generating contextual paths in validation messages.- Parameters:
formatter- the path formatter to use
-
toPath
Get the path of the provided item using the configured path formatter.- Parameters:
item- the node item to generate the path for- Returns:
- the path
- See Also:
-
newCardinalityMinimumViolationMessage
@NonNull protected String newCardinalityMinimumViolationMessage(@NonNull ICardinalityConstraint constraint, @NonNull INodeItem target, @NonNull ISequence<? extends INodeItem> testedItems, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains totarget- the item the constraint targetedtestedItems- the items tested by the constraintdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newCardinalityMaximumViolationMessage
@NonNull protected String newCardinalityMaximumViolationMessage(@NonNull ICardinalityConstraint constraint, @NonNull INodeItem target, @NonNull ISequence<? extends INodeItem> testedItems, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains totarget- the item the constraint targetedtestedItems- the items tested by the constraintdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newIndexDuplicateKeyViolationMessage
@NonNull protected String newIndexDuplicateKeyViolationMessage(@NonNull IIndexConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem oldItem, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targetedoldItem- the original item matching the constrainttarget- the new item matching the constraintdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newUniqueKeyViolationMessage
@NonNull protected String newUniqueKeyViolationMessage(@NonNull IUniqueConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem oldItem, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targetedoldItem- the original item matching the constrainttarget- the new item matching the constraintdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newMatchPatternViolationMessage
@NonNull protected String newMatchPatternViolationMessage(@NonNull IMatchesConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String value, @NonNull Pattern pattern, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targetedtarget- the target matching the constraintvalue- the target's valuepattern- the expected patterndynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newMatchDatatypeViolationMessage
@NonNull protected String newMatchDatatypeViolationMessage(@NonNull IMatchesConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String value, @NonNull IDataTypeAdapter<?> adapter, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targetedtarget- the target matching the constraintvalue- the target's valueadapter- the expected data type adapterdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newExpectViolationMessage
@NonNull protected String newExpectViolationMessage(@NonNull IExpectConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targetedtarget- the target matching the constraintdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newReportViolationMessage
@NonNull protected String newReportViolationMessage(@NonNull IReportConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new message for the provided reportconstraintapplied to thenode.Report constraints generate findings when their test expression evaluates to
true, which is the opposite of expect constraints.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targetedtarget- the target matching the constraintdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newAllowedValuesViolationMessage
@NonNull protected String newAllowedValuesViolationMessage(@NonNull List<IAllowedValuesConstraint> constraints, @NonNull INodeItem target) Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraints- the constraints the requested message pertains totarget- the target matching the constraint- Returns:
- the new message
-
newIndexDuplicateViolationMessage
@NonNull protected String newIndexDuplicateViolationMessage(@NonNull IIndexConstraint constraint, @NonNull INodeItem node) Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targeted- Returns:
- the new message
-
newIndexMissMessage
@NonNull protected String newIndexMissMessage(@NonNull IIndexHasKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull List<String> key, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException Construct a new violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targetedtarget- the target matching the constraintkey- the key derived from the target that failed to be found in the indexdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
- Throws:
ConstraintValidationException- if the custom message contains a Metapath expression that is invalid or if the expression failed to evaluate
-
newMissingIndexViolationMessage
@NonNull protected String newMissingIndexViolationMessage(@NonNull IIndexHasKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String message, @NonNull DynamicContext dynamicContext) Construct a new generic violation message for the providedconstraintapplied to thenode.- Parameters:
constraint- the constraint the requested message pertains tonode- the item the constraint targetedtarget- the target matching the constraintmessage- the message to be added before information about the target pathdynamicContext- the Metapath dynamic execution context to use for Metapath evaluation- Returns:
- the new message
-