1 package gov.nist.secauto.oscal.lib.model;
2
3 import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
4 import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
5 import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
6 import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
7 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
8 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
9 import gov.nist.secauto.metaschema.binding.model.annotations.Expect;
10 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
11 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
12 import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
13 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
14 import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
15 import gov.nist.secauto.metaschema.model.common.datatype.adapter.BooleanAdapter;
16 import gov.nist.secauto.metaschema.model.common.datatype.adapter.StringAdapter;
17 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
18 import java.lang.Boolean;
19 import java.lang.Override;
20 import java.lang.String;
21 import java.util.LinkedList;
22 import java.util.List;
23 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
24 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
25
26
27
28
29 @MetaschemaAssembly(
30 formalName = "Merge Controls",
31 description = "Provides structuring directives that instruct how controls are organized after profile resolution.",
32 name = "merge",
33 metaschema = OscalProfileMetaschema.class
34 )
35 public class Merge {
36
37
38
39 @BoundAssembly(
40 formalName = "Combination Rule",
41 description = "A Combine element defines how to resolve duplicate instances of the same control (e.g., controls with the same ID).",
42 useName = "combine"
43 )
44 private Combine _combine;
45
46
47
48
49 @BoundAssembly(
50 formalName = "Flat Without Grouping",
51 description = "Directs that controls appear without any grouping structure.",
52 useName = "flat",
53 minOccurs = 1
54 )
55 private Flat _flat;
56
57
58
59
60 @BoundField(
61 formalName = "Group As-Is",
62 description = "Indicates that the controls selected should retain their original grouping as defined in the import source.",
63 useName = "as-is",
64 minOccurs = 1
65 )
66 @BoundFieldValue(
67 typeAdapter = BooleanAdapter.class
68 )
69 private Boolean _asIs;
70
71
72
73
74 @BoundAssembly(
75 formalName = "Custom Grouping",
76 description = "Provides an alternate grouping structure that selected controls will be placed in.",
77 useName = "custom",
78 minOccurs = 1,
79 remarks = "The `custom` element represents a custom arrangement or organization of controls in the resolution of a catalog. This structuring directive gives the profile author the ability to define an entirely different organization of controls as compared to their source catalog(s)."
80 )
81 private Custom _custom;
82
83 public Merge() {
84 }
85
86 public Combine getCombine() {
87 return _combine;
88 }
89
90 public void setCombine(Combine value) {
91 _combine = value;
92 }
93
94 public Flat getFlat() {
95 return _flat;
96 }
97
98 public void setFlat(Flat value) {
99 _flat = value;
100 }
101
102 public Boolean getAsIs() {
103 return _asIs;
104 }
105
106 public void setAsIs(Boolean value) {
107 _asIs = value;
108 }
109
110 public Custom getCustom() {
111 return _custom;
112 }
113
114 public void setCustom(Custom value) {
115 _custom = value;
116 }
117
118 @Override
119 public String toString() {
120 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
121 }
122
123
124
125
126 @MetaschemaAssembly(
127 formalName = "Combination Rule",
128 description = "A Combine element defines how to resolve duplicate instances of the same control (e.g., controls with the same ID).",
129 name = "combine",
130 metaschema = OscalProfileMetaschema.class
131 )
132 @ValueConstraints(
133 expect = @Expect(id = "req-merge-combine", level = IConstraint.Level.ERROR, test = "not(@method='merge')")
134 )
135 public static class Combine {
136 @BoundFlag(
137 formalName = "Combination Method",
138 description = "Declare how clashing controls should be handled.",
139 useName = "method",
140 typeAdapter = StringAdapter.class
141 )
142 @ValueConstraints(
143 allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "use-first", description = "Use the first definition - the first control with a given ID is used; subsequent ones are discarded"), @AllowedValue(value = "merge", description = "\\*\\*(*deprecated* )\\*\\* \\*\\*(*unspecified*)\\*\\* Merge - controls with the same ID are combined"), @AllowedValue(value = "keep", description = "Keep - controls with the same ID are kept, retaining the clash")})
144 )
145 private String _method;
146
147 public Combine() {
148 }
149
150 public String getMethod() {
151 return _method;
152 }
153
154 public void setMethod(String value) {
155 _method = value;
156 }
157
158 @Override
159 public String toString() {
160 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
161 }
162 }
163
164
165
166
167 @MetaschemaAssembly(
168 formalName = "Flat Without Grouping",
169 description = "Directs that controls appear without any grouping structure.",
170 name = "flat",
171 metaschema = OscalProfileMetaschema.class
172 )
173 public static class Flat {
174 public Flat() {
175 }
176
177 @Override
178 public String toString() {
179 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
180 }
181 }
182
183
184
185
186 @MetaschemaAssembly(
187 formalName = "Custom Grouping",
188 description = "Provides an alternate grouping structure that selected controls will be placed in.",
189 name = "custom",
190 metaschema = OscalProfileMetaschema.class,
191 remarks = "The `custom` element represents a custom arrangement or organization of controls in the resolution of a catalog. This structuring directive gives the profile author the ability to define an entirely different organization of controls as compared to their source catalog(s)."
192 )
193 public static class Custom {
194 @BoundAssembly(
195 formalName = "Control Group",
196 description = "A group of (selected) controls or of groups of controls.",
197 useName = "group",
198 maxOccurs = -1
199 )
200 @GroupAs(
201 name = "groups",
202 inJson = JsonGroupAsBehavior.LIST
203 )
204 private List<ProfileGroup> _groups;
205
206 @BoundAssembly(
207 formalName = "Insert Controls",
208 description = "Specifies which controls to use in the containing context.",
209 useName = "insert-controls",
210 maxOccurs = -1
211 )
212 @GroupAs(
213 name = "insert-controls",
214 inJson = JsonGroupAsBehavior.LIST
215 )
216 private List<InsertControls> _insertControls;
217
218 public Custom() {
219 }
220
221 public List<ProfileGroup> getGroups() {
222 return _groups;
223 }
224
225 public void setGroups(List<ProfileGroup> value) {
226 _groups = value;
227 }
228
229
230
231
232
233
234 public boolean addGroup(ProfileGroup item) {
235 ProfileGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
236 if (_groups == null) {
237 _groups = new LinkedList<>();
238 }
239 return _groups.add(value);
240 }
241
242
243
244
245
246
247 public boolean removeGroup(ProfileGroup item) {
248 ProfileGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
249 return _groups == null ? false : _groups.remove(value);
250 }
251
252 public List<InsertControls> getInsertControls() {
253 return _insertControls;
254 }
255
256 public void setInsertControls(List<InsertControls> value) {
257 _insertControls = value;
258 }
259
260
261
262
263
264
265 public boolean addInsertControls(InsertControls item) {
266 InsertControls value = ObjectUtils.requireNonNull(item,"item cannot be null");
267 if (_insertControls == null) {
268 _insertControls = new LinkedList<>();
269 }
270 return _insertControls.add(value);
271 }
272
273
274
275
276
277
278 public boolean removeInsertControls(InsertControls item) {
279 InsertControls value = ObjectUtils.requireNonNull(item,"item cannot be null");
280 return _insertControls == null ? false : _insertControls.remove(value);
281 }
282
283 @Override
284 public String toString() {
285 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
286 }
287 }
288 }