Module dev.metaschema.core
Class AbstractTargetedConstraints<T extends IValueConstrained>
java.lang.Object
dev.metaschema.core.model.constraint.AbstractTargetedConstraints<T>
- Type Parameters:
T- the Java type of the constraint container
- All Implemented Interfaces:
IFeatureValueConstrained,ITargetedConstraints,IValueConstrained
- Direct Known Subclasses:
FieldTargetedConstraints,FlagTargetedConstraints,ModelTargetedConstraints
public abstract class AbstractTargetedConstraints<T extends IValueConstrained>
extends Object
implements ITargetedConstraints, IFeatureValueConstrained
Provides an base implementation for a set of constraints that target a
definition using a target Metapath expression.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractTargetedConstraints(ISource source, Supplier<List<IMetapathExpression>> targets, T constraints) Construct a new set of targeted constraints. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyTo(IValueConstrained definition) Apply the constraints to the provideddefinition.Lazy initialize the instances for the constraints when the constraints are first accessed.Get information about the resource the constraints were loaded from.Get the Metapath expressions used to identify the targets of the constraint.voidtarget(IAssemblyDefinition definition) Apply the constraint to the provided definition.voidtarget(IFieldDefinition definition) Apply the constraint to the provided definition.voidtarget(IFlagDefinition definition) Apply the constraint to the provided definition.protected voidwrongDefinitionTypeTargeted(IDefinition definition) Throws aConstraintInitializationExceptionindicating that the constraint target is not valid.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.IFeatureValueConstrained
addConstraint, addConstraint, addConstraint, addConstraint, addConstraint, addLetExpression, getAllowedValuesConstraints, getConstraints, getExpectConstraints, getIndexHasKeyConstraints, getLetExpressions, getMatchesConstraints, getReportConstraints
-
Constructor Details
-
AbstractTargetedConstraints
protected AbstractTargetedConstraints(@NonNull ISource source, @NonNull Supplier<List<IMetapathExpression>> targets, @NonNull T constraints) Construct a new set of targeted constraints.- Parameters:
source- information about the resource the constraints were sources fromtargets- a supplier to get the Metapath expressions that can be used to find matching targetsconstraints- the constraints to apply to matching targets
-
-
Method Details
-
getSource
Description copied from interface:IValueConstrainedGet information about the resource the constraints were loaded from.- Specified by:
getSourcein interfaceIValueConstrained- Returns:
- the source information
-
getTargets
Description copied from interface:ITargetedConstraintsGet the Metapath expressions used to identify the targets of the constraint.- Specified by:
getTargetsin interfaceITargetedConstraints- Returns:
- the Metapath expressions identifying the targets of the associated constraints
-
getConstraintSupport
Description copied from interface:IFeatureValueConstrainedLazy initialize the instances for the constraints when the constraints are first accessed.- Specified by:
getConstraintSupportin interfaceIFeatureValueConstrained- Returns:
- the constraints instance
-
applyTo
Apply the constraints to the provideddefinition.This will be called when a definition is found that matches the target expression.
- Parameters:
definition- the definition to apply the constraints to.
-
target
Description copied from interface:ITargetedConstraintsApply the constraint to the provided definition.- Specified by:
targetin interfaceITargetedConstraints- Parameters:
definition- the definition to apply the constraint to
-
target
Description copied from interface:ITargetedConstraintsApply the constraint to the provided definition.- Specified by:
targetin interfaceITargetedConstraints- Parameters:
definition- the definition to apply the constraint to
-
target
Description copied from interface:ITargetedConstraintsApply the constraint to the provided definition.- Specified by:
targetin interfaceITargetedConstraints- Parameters:
definition- the definition to apply the constraint to
-
wrongDefinitionTypeTargeted
Throws aConstraintInitializationExceptionindicating that the constraint target is not valid.- Parameters:
definition- the targeted definition- Throws:
ConstraintInitializationException- when method is called to indicate that the provided definition is not a valid constraint target
-