Class ScopedConstraintSet

java.lang.Object
dev.metaschema.core.model.constraint.ScopedConstraintSet
All Implemented Interfaces:
IConstraintSet

public class ScopedConstraintSet extends Object implements IConstraintSet
The default implementation of a constraint set sourced from an external constraint resource.
  • Constructor Details

    • ScopedConstraintSet

      public ScopedConstraintSet(@NonNull ISource source, @NonNull List<IScopedContraints> scopedContraints, @NonNull Set<IConstraintSet> importedConstraintSets)
      Construct a new constraint set.
      Parameters:
      source - the resource the constraint was provided from
      scopedContraints - a set of constraints qualified by a scope path
      importedConstraintSets - constraint sets imported by this constraint set
  • Method Details

    • getSource

      public ISource getSource()
      Get the resource the constraint was provided from.
      Specified by:
      getSource in interface IConstraintSet
      Returns:
      the resource
    • getScopedContraints

      @NonNull public Map<IEnhancedQName,List<IScopedContraints>> getScopedContraints()
      Get the set of Metaschema scoped constraints to apply by a QName formed from the Metaschema namespace and short name.
      Returns:
      the mapping of QName to scoped constraints
    • getImportedConstraintSets

      public Set<IConstraintSet> getImportedConstraintSets()
      Description copied from interface: IConstraintSet
      Get constraint sets imported by this constraint set.
      Specified by:
      getImportedConstraintSets in interface IConstraintSet
      Returns:
      the imported constraint sets
    • applyConstraintsForModule

      public void applyConstraintsForModule(IModuleNodeItem moduleItem, IModelElementVisitor<ITargetedConstraints,Void> visitor)
      Description copied from interface: IConstraintSet
      Apply the constraints associated with this constraint set to the provided module, if applicable.

      Callers of this method are required to track which definitions have been previously targeted based on the result of this method and to provide these to subsequent calls of this method targeting different modules. This approach ensures that a given constraint is not applied more than once.

      Specified by:
      applyConstraintsForModule in interface IConstraintSet
      Parameters:
      moduleItem - the module node item to apply applicable constraints to
      visitor - the visitor used to apply constraints to target definitions