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.model.ISource;
9 import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
10
11 import java.util.List;
12 import java.util.Map;
13
14 import edu.umd.cs.findbugs.annotations.NonNull;
15
16 /**
17 * Represents a container of rules constraining the effective model of a
18 * Metaschema field or flag data instance.
19 */
20 public interface IValueConstrained {
21 /**
22 * Get information about the resource the constraints were loaded from.
23 *
24 * @return the source information
25 */
26 @NonNull
27 ISource getSource();
28
29 /**
30 * Retrieve the ordered collection of constraints.
31 *
32 * @return the constraints or an empty list
33 */
34 @NonNull
35 List<? extends IConstraint> getConstraints();
36
37 /**
38 * Get the collection of let expressions, if any.
39 *
40 * @return the constraints or an empty list
41 */
42 @NonNull
43 Map<IEnhancedQName, ILet> getLetExpressions();
44
45 /**
46 * Get the collection of allowed value constraints, if any.
47 *
48 * @return the constraints or an empty list
49 */
50 @NonNull
51 List<? extends IAllowedValuesConstraint> getAllowedValuesConstraints();
52
53 /**
54 * Get the collection of matches constraints, if any.
55 *
56 * @return the constraints or an empty list
57 */
58 @NonNull
59 List<? extends IMatchesConstraint> getMatchesConstraints();
60
61 /**
62 * Get the collection of index key reference constraints, if any.
63 *
64 * @return the constraints or an empty list
65 */
66 @NonNull
67 List<? extends IIndexHasKeyConstraint> getIndexHasKeyConstraints();
68
69 /**
70 * Get the collection of expect constraints, if any.
71 *
72 * @return the constraints or an empty list
73 */
74 @NonNull
75 List<? extends IExpectConstraint> getExpectConstraints();
76
77 /**
78 * Add a new let expression.
79 *
80 * @param let
81 * the let statement to add
82 * @return the original let with the same name or {@code null} if no let existed
83 * with the same name
84 */
85 ILet addLetExpression(@NonNull ILet let);
86
87 /**
88 * Add a new constraint.
89 *
90 * @param constraint
91 * the constraint to add
92 */
93 void addConstraint(@NonNull IAllowedValuesConstraint constraint);
94
95 /**
96 * Add a new constraint.
97 *
98 * @param constraint
99 * the constraint to add
100 */
101 void addConstraint(@NonNull IMatchesConstraint constraint);
102
103 /**
104 * Add a new constraint.
105 *
106 * @param constraint
107 * the constraint to add
108 */
109 void addConstraint(@NonNull IIndexHasKeyConstraint constraint);
110
111 /**
112 * Add a new constraint.
113 *
114 * @param constraint
115 * the constraint to add
116 */
117 void addConstraint(@NonNull IExpectConstraint constraint);
118 }