1
2
3
4
5
6 package gov.nist.secauto.metaschema.core.model.constraint;
7
8 import gov.nist.secauto.metaschema.core.metapath.MetapathException;
9 import gov.nist.secauto.metaschema.core.metapath.MetapathExpression;
10 import gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultLet;
11
12 import javax.xml.namespace.QName;
13
14 import edu.umd.cs.findbugs.annotations.NonNull;
15
16 @SuppressWarnings("PMD.ShortClassName")
17 public interface ILet {
18
19
20
21
22
23
24
25
26
27
28
29
30 @SuppressWarnings("PMD.ShortMethodName")
31 @NonNull
32 static ILet of(
33 @NonNull QName name,
34 @NonNull String valueExpression,
35 @NonNull ISource source) {
36 try {
37 return of(name, MetapathExpression.compile(valueExpression, source.getStaticContext()), source);
38 } catch (MetapathException ex) {
39 throw new MetapathException(
40 String.format("Unable to compile the let expression '%s=%s'%s. %s",
41 name,
42 valueExpression,
43 source.getSource() == null ? "" : " in " + source.getSource(),
44 ex.getMessage()),
45 ex);
46 }
47 }
48
49
50
51
52
53
54
55
56
57
58
59
60 @SuppressWarnings("PMD.ShortMethodName")
61 @NonNull
62 static ILet of(
63 @NonNull QName name,
64 @NonNull MetapathExpression valueExpression,
65 @NonNull ISource source) {
66 return new DefaultLet(name, valueExpression, source);
67 }
68
69
70
71
72
73
74 @NonNull
75 QName getName();
76
77
78
79
80
81
82 @NonNull
83 MetapathExpression getValueExpression();
84
85
86
87
88
89
90 @NonNull
91 ISource getSource();
92 }