1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package gov.nist.secauto.metaschema.core.model.constraint;
7
8 import gov.nist.secauto.metaschema.core.metapath.item.node.IModuleNodeItem;
9 import gov.nist.secauto.metaschema.core.model.IModelElementVisitor;
10 import gov.nist.secauto.metaschema.core.model.ISource;
11
12 import java.util.Collection;
13
14 import edu.umd.cs.findbugs.annotations.NonNull;
15
16 /**
17 * A set of constraints targeted at the contents of a Metaschema module.
18 */
19 public interface IConstraintSet {
20 /**
21 * Get information about where the constraint set was sourced from.
22 *
23 * @return the source information
24 */
25 @NonNull
26 ISource getSource();
27
28 /**
29 * Get constraint sets imported by this constraint set.
30 *
31 * @return the imported constraint sets
32 */
33 @NonNull
34 Collection<? extends IConstraintSet> getImportedConstraintSets();
35
36 /**
37 * Apply the constraints associated with this constraint set to the provided
38 * module, if applicable.
39 * <p>
40 * Callers of this method are required to track which definitions have been
41 * previously targeted based on the result of this method and to provide these
42 * to subsequent calls of this method targeting different modules. This approach
43 * ensures that a given constraint is not applied more than once.
44 *
45 * @param moduleItem
46 * the module node item to apply applicable constraints to
47 * @param visitor
48 * the visitor used to apply constraints to target definitions
49 */
50 void applyConstraintsForModule(
51 @NonNull IModuleNodeItem moduleItem,
52 @NonNull IModelElementVisitor<ITargetedConstraints, Void> visitor);
53 }