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.datatype.markup.MarkupMultiline;
9 import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression;
10 import gov.nist.secauto.metaschema.core.model.ISource;
11 import gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultLet;
12 import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
13
14 import edu.umd.cs.findbugs.annotations.NonNull;
15 import edu.umd.cs.findbugs.annotations.Nullable;
16
17 /**
18 * Represents a variable assignment for use in Metaschema module constraints.
19 */
20 public interface ILet {
21 /**
22 * Create a new Let expression by compiling the provided Metapath expression
23 * string.
24 * <p>
25 * This method is deprecated. Callers should use
26 * {@link #of(IEnhancedQName, IMetapathExpression, ISource, MarkupMultiline)}
27 * instead.
28 *
29 * @param name
30 * the let expression variable name
31 * @param valueExpression
32 * a Metapath expression string representing the variable value
33 * @param source
34 * the source descriptor for the resource containing the constraint
35 * @param remarks
36 * remarks about the let statement
37 * @return the original let statement with the same name or {@code null}
38 */
39 @NonNull
40 @Deprecated(since = "2.2.0", forRemoval = true)
41 static ILet of(
42 @NonNull IEnhancedQName name,
43 @NonNull String valueExpression,
44 @NonNull ISource source,
45 @Nullable MarkupMultiline remarks) {
46 return of(
47 name,
48 IMetapathExpression.lazyCompile(valueExpression, source.getStaticContext()),
49 source,
50 remarks);
51 }
52
53 /**
54 * Create a new Let expression.
55 *
56 * @param name
57 * the let expression variable name
58 * @param valueExpression
59 * a Metapath expression representing the variable value
60 * @param source
61 * the source descriptor for the resource containing the constraint
62 * @param remarks
63 * remarks about the let statement
64 * @return the original let statement with the same name or {@code null}
65 */
66 @NonNull
67 static ILet of(
68 @NonNull IEnhancedQName name,
69 @NonNull IMetapathExpression valueExpression,
70 @NonNull ISource source,
71 @Nullable MarkupMultiline remarks) {
72 return new DefaultLet(name, valueExpression, source, remarks);
73 }
74
75 /**
76 * Get the name of the let variable.
77 *
78 * @return the name
79 */
80 @NonNull
81 IEnhancedQName getName();
82
83 /**
84 * Get the Metapath expression to use to query the value.
85 *
86 * @return the Metapath expression to use to query the value
87 */
88 @NonNull
89 IMetapathExpression getValueExpression();
90
91 /**
92 * Information about the source resource containing the let statement.
93 *
94 * @return the source information
95 */
96 @NonNull
97 ISource getSource();
98
99 /**
100 * Get the remarks associated with the let statement.
101 *
102 * @return the remark or {@code null} if no remarks are defined
103 */
104 @Nullable
105 MarkupMultiline getRemarks();
106 }