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