1
2
3
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.MetapathException;
10 import gov.nist.secauto.metaschema.core.metapath.MetapathExpression;
11 import gov.nist.secauto.metaschema.core.model.ISource;
12 import gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultLet;
13 import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
14
15 import edu.umd.cs.findbugs.annotations.NonNull;
16 import edu.umd.cs.findbugs.annotations.Nullable;
17
18
19
20
21 @SuppressWarnings("PMD.ShortClassName")
22 public interface ILet {
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 @SuppressWarnings("PMD.ShortMethodName")
38 @NonNull
39 static ILet of(
40 @NonNull IEnhancedQName name,
41 @NonNull String valueExpression,
42 @NonNull ISource source,
43 @Nullable MarkupMultiline remarks) {
44 try {
45 return of(
46 name,
47 MetapathExpression.compile(valueExpression, source.getStaticContext()),
48 source,
49 remarks);
50 } catch (MetapathException ex) {
51 throw new MetapathException(
52 String.format("Unable to compile the let expression '%s=%s'%s. %s",
53 name,
54 valueExpression,
55 source.getSource() == null ? "" : " in " + source.getSource(),
56 ex.getMessage()),
57 ex);
58 }
59 }
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 @SuppressWarnings("PMD.ShortMethodName")
75 @NonNull
76 static ILet of(
77 @NonNull IEnhancedQName name,
78 @NonNull MetapathExpression valueExpression,
79 @NonNull ISource source,
80 @Nullable MarkupMultiline remarks) {
81 return new DefaultLet(name, valueExpression, source, remarks);
82 }
83
84
85
86
87
88
89 @NonNull
90 IEnhancedQName getName();
91
92
93
94
95
96
97 @NonNull
98 MetapathExpression getValueExpression();
99
100
101
102
103
104
105 @NonNull
106 ISource getSource();
107
108
109
110
111
112
113 @Nullable
114 MarkupMultiline getRemarks();
115 }