1 package gov.nist.secauto.oscal.lib.model;
2
3 import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
4 import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
5 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
6 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
7 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
8 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
9 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
10 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
11 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
12 import java.lang.Override;
13 import java.lang.String;
14 import java.util.LinkedList;
15 import java.util.List;
16 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
17 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
18
19
20
21
22 @MetaschemaAssembly(
23 formalName = "Constraint",
24 description = "A formal or informal expression of a constraint or test.",
25 name = "parameter-constraint",
26 metaschema = OscalControlCommonMetaschema.class
27 )
28 public class ParameterConstraint {
29
30
31
32 @BoundField(
33 formalName = "Constraint Description",
34 description = "A textual summary of the constraint to be applied.",
35 useName = "description"
36 )
37 @BoundFieldValue(
38 typeAdapter = MarkupMultilineAdapter.class
39 )
40 private MarkupMultiline _description;
41
42
43
44
45 @BoundAssembly(
46 formalName = "Constraint Test",
47 description = "A test expression which is expected to be evaluated by a tool.",
48 useName = "test",
49 maxOccurs = -1
50 )
51 @GroupAs(
52 name = "tests",
53 inJson = JsonGroupAsBehavior.LIST
54 )
55 private List<Test> _tests;
56
57 public ParameterConstraint() {
58 }
59
60 public MarkupMultiline getDescription() {
61 return _description;
62 }
63
64 public void setDescription(MarkupMultiline value) {
65 _description = value;
66 }
67
68 public List<Test> getTests() {
69 return _tests;
70 }
71
72 public void setTests(List<Test> value) {
73 _tests = value;
74 }
75
76
77
78
79
80
81 public boolean addTest(Test item) {
82 Test value = ObjectUtils.requireNonNull(item,"item cannot be null");
83 if (_tests == null) {
84 _tests = new LinkedList<>();
85 }
86 return _tests.add(value);
87 }
88
89
90
91
92
93
94 public boolean removeTest(Test item) {
95 Test value = ObjectUtils.requireNonNull(item,"item cannot be null");
96 return _tests == null ? false : _tests.remove(value);
97 }
98
99 @Override
100 public String toString() {
101 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
102 }
103
104
105
106
107 @MetaschemaAssembly(
108 formalName = "Constraint Test",
109 description = "A test expression which is expected to be evaluated by a tool.",
110 name = "test",
111 metaschema = OscalControlCommonMetaschema.class
112 )
113 public static class Test {
114
115
116
117 @BoundField(
118 formalName = "Constraint test",
119 description = "A formal (executable) expression of a constraint.",
120 useName = "expression",
121 minOccurs = 1
122 )
123 private String _expression;
124
125 @BoundField(
126 formalName = "Remarks",
127 description = "Additional commentary about the containing object.",
128 useName = "remarks"
129 )
130 @BoundFieldValue(
131 typeAdapter = MarkupMultilineAdapter.class
132 )
133 private MarkupMultiline _remarks;
134
135 public Test() {
136 }
137
138 public String getExpression() {
139 return _expression;
140 }
141
142 public void setExpression(String value) {
143 _expression = value;
144 }
145
146 public MarkupMultiline getRemarks() {
147 return _remarks;
148 }
149
150 public void setRemarks(MarkupMultiline value) {
151 _remarks = value;
152 }
153
154 @Override
155 public String toString() {
156 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
157 }
158 }
159 }