001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_assessment-common_metaschema.xml
002// Do not edit - changes will be lost when regenerated.
003package dev.metaschema.oscal.lib.model;
004
005import dev.metaschema.core.datatype.adapter.TokenAdapter;
006import dev.metaschema.core.datatype.adapter.UuidAdapter;
007import dev.metaschema.core.datatype.markup.MarkupLine;
008import dev.metaschema.core.datatype.markup.MarkupLineAdapter;
009import dev.metaschema.core.datatype.markup.MarkupMultiline;
010import dev.metaschema.core.datatype.markup.MarkupMultilineAdapter;
011import dev.metaschema.core.model.IBoundObject;
012import dev.metaschema.core.model.IMetaschemaData;
013import dev.metaschema.core.model.JsonGroupAsBehavior;
014import dev.metaschema.core.model.constraint.IConstraint;
015import dev.metaschema.core.util.ObjectUtils;
016import dev.metaschema.databind.model.annotations.AllowedValue;
017import dev.metaschema.databind.model.annotations.AllowedValues;
018import dev.metaschema.databind.model.annotations.BoundAssembly;
019import dev.metaschema.databind.model.annotations.BoundField;
020import dev.metaschema.databind.model.annotations.BoundFlag;
021import dev.metaschema.databind.model.annotations.GroupAs;
022import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
023import dev.metaschema.databind.model.annotations.ValueConstraints;
024import edu.umd.cs.findbugs.annotations.NonNull;
025import edu.umd.cs.findbugs.annotations.Nullable;
026import java.util.LinkedList;
027import java.util.List;
028import java.util.UUID;
029import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
030import org.apache.commons.lang3.builder.ToStringStyle;
031
032/**
033 * A <a href="https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented">human-oriented</a> identifier reference to a resource. Use type to indicate whether the identified resource is a component, inventory item, location, user, or something else.
034 */
035@MetaschemaAssembly(
036    formalName = "Identifies the Subject",
037    description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) identifier reference to a resource. Use type to indicate whether the identified resource is a component, inventory item, location, user, or something else.",
038    name = "subject-reference",
039    moduleClass = OscalAssessmentCommonModule.class,
040    remarks = "The subject reference UUID could point to an item defined in the SSP, AP, or AR.\n"
041            + "\n"
042            + "Tools should check look for the ID in every file imported directly or indirectly."
043)
044public class SubjectReference implements IBoundObject {
045  private final IMetaschemaData __metaschemaData;
046
047  /**
048   * A <a href="https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented">machine-oriented</a> identifier reference to a component, inventory-item, location, party, user, or resource using it's UUID.
049   */
050  @BoundFlag(
051      formalName = "Subject Universally Unique Identifier Reference",
052      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a component, inventory-item, location, party, user, or resource using it's UUID.",
053      name = "subject-uuid",
054      required = true,
055      typeAdapter = UuidAdapter.class
056  )
057  private UUID _subjectUuid;
058
059  /**
060   * Used to indicate the type of object pointed to by the <code>uuid-ref</code> within a subject.
061   */
062  @BoundFlag(
063      formalName = "Subject Universally Unique Identifier Reference Type",
064      description = "Used to indicate the type of object pointed to by the `uuid-ref` within a subject.",
065      name = "type",
066      required = true,
067      typeAdapter = TokenAdapter.class,
068      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(id = "oscal-assessment-subject-type-values", level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "component", description = "Component"), @AllowedValue(value = "inventory-item", description = "Inventory Item"), @AllowedValue(value = "location", description = "Location"), @AllowedValue(value = "party", description = "Interview Party"), @AllowedValue(value = "user", description = "User"), @AllowedValue(value = "resource", description = "Resource or Artifact")}))
069  )
070  private String _type;
071
072  /**
073   * The title or name for the referenced subject.
074   */
075  @BoundField(
076      formalName = "Subject Reference Title",
077      description = "The title or name for the referenced subject.",
078      useName = "title",
079      typeAdapter = MarkupLineAdapter.class
080  )
081  private MarkupLine _title;
082
083  /**
084   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
085   */
086  @BoundAssembly(
087      formalName = "Property",
088      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
089      useName = "prop",
090      maxOccurs = -1,
091      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
092  )
093  private List<Property> _props;
094
095  /**
096   * A reference to a local or remote resource, that has a specific relation to the containing object.
097   */
098  @BoundAssembly(
099      formalName = "Link",
100      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
101      useName = "link",
102      maxOccurs = -1,
103      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
104  )
105  private List<Link> _links;
106
107  /**
108   * Additional commentary about the containing object.
109   */
110  @BoundField(
111      formalName = "Remarks",
112      description = "Additional commentary about the containing object.",
113      useName = "remarks",
114      typeAdapter = MarkupMultilineAdapter.class
115  )
116  private MarkupMultiline _remarks;
117
118  /**
119   * Constructs a new {@code dev.metaschema.oscal.lib.model.SubjectReference} instance with no metadata.
120   */
121  public SubjectReference() {
122    this(null);
123  }
124
125  /**
126   * Constructs a new {@code dev.metaschema.oscal.lib.model.SubjectReference} instance with the specified metadata.
127   *
128   * @param data
129   *           the metaschema data, or {@code null} if none
130   */
131  public SubjectReference(IMetaschemaData data) {
132    this.__metaschemaData = data;
133  }
134
135  @Override
136  public IMetaschemaData getMetaschemaData() {
137    return __metaschemaData;
138  }
139
140  /**
141   * Get the "{@literal Subject Universally Unique Identifier Reference}".
142   *
143   * <p>
144   * A <a href="https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented">machine-oriented</a> identifier reference to a component, inventory-item, location, party, user, or resource using it's UUID.
145   *
146   * @return the subject-uuid value
147   */
148  @NonNull
149  public UUID getSubjectUuid() {
150    return _subjectUuid;
151  }
152
153  /**
154   * Set the "{@literal Subject Universally Unique Identifier Reference}".
155   *
156   * <p>
157   * A <a href="https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented">machine-oriented</a> identifier reference to a component, inventory-item, location, party, user, or resource using it's UUID.
158   *
159   * @param value
160   *           the subject-uuid value to set
161   */
162  public void setSubjectUuid(@NonNull UUID value) {
163    _subjectUuid = value;
164  }
165
166  /**
167   * Get the "{@literal Subject Universally Unique Identifier Reference Type}".
168   *
169   * <p>
170   * Used to indicate the type of object pointed to by the <code>uuid-ref</code> within a subject.
171   *
172   * @return the type value
173   */
174  @NonNull
175  public String getType() {
176    return _type;
177  }
178
179  /**
180   * Set the "{@literal Subject Universally Unique Identifier Reference Type}".
181   *
182   * <p>
183   * Used to indicate the type of object pointed to by the <code>uuid-ref</code> within a subject.
184   *
185   * @param value
186   *           the type value to set
187   */
188  public void setType(@NonNull String value) {
189    _type = value;
190  }
191
192  /**
193   * Get the "{@literal Subject Reference Title}".
194   *
195   * <p>
196   * The title or name for the referenced subject.
197   *
198   * @return the title value, or {@code null} if not set
199   */
200  @Nullable
201  public MarkupLine getTitle() {
202    return _title;
203  }
204
205  /**
206   * Set the "{@literal Subject Reference Title}".
207   *
208   * <p>
209   * The title or name for the referenced subject.
210   *
211   * @param value
212   *           the title value to set, or {@code null} to clear
213   */
214  public void setTitle(@Nullable MarkupLine value) {
215    _title = value;
216  }
217
218  /**
219   * Get the "{@literal Property}".
220   *
221   * <p>
222   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
223   *
224   * @return the prop value
225   */
226  @NonNull
227  public List<Property> getProps() {
228    if (_props == null) {
229      _props = new LinkedList<>();
230    }
231    return ObjectUtils.notNull(_props);
232  }
233
234  /**
235   * Set the "{@literal Property}".
236   *
237   * <p>
238   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
239   *
240   * @param value
241   *           the prop value to set
242   */
243  public void setProps(@NonNull List<Property> value) {
244    _props = value;
245  }
246
247  /**
248   * Add a new {@link Property} item to the underlying collection.
249   * @param item the item to add
250   * @return {@code true}
251   */
252  public boolean addProp(Property item) {
253    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
254    if (_props == null) {
255      _props = new LinkedList<>();
256    }
257    return _props.add(value);
258  }
259
260  /**
261   * Remove the first matching {@link Property} item from the underlying collection.
262   * @param item the item to remove
263   * @return {@code true} if the item was removed or {@code false} otherwise
264   */
265  public boolean removeProp(Property item) {
266    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
267    return _props != null && _props.remove(value);
268  }
269
270  /**
271   * Get the "{@literal Link}".
272   *
273   * <p>
274   * A reference to a local or remote resource, that has a specific relation to the containing object.
275   *
276   * @return the link value
277   */
278  @NonNull
279  public List<Link> getLinks() {
280    if (_links == null) {
281      _links = new LinkedList<>();
282    }
283    return ObjectUtils.notNull(_links);
284  }
285
286  /**
287   * Set the "{@literal Link}".
288   *
289   * <p>
290   * A reference to a local or remote resource, that has a specific relation to the containing object.
291   *
292   * @param value
293   *           the link value to set
294   */
295  public void setLinks(@NonNull List<Link> value) {
296    _links = value;
297  }
298
299  /**
300   * Add a new {@link Link} item to the underlying collection.
301   * @param item the item to add
302   * @return {@code true}
303   */
304  public boolean addLink(Link item) {
305    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
306    if (_links == null) {
307      _links = new LinkedList<>();
308    }
309    return _links.add(value);
310  }
311
312  /**
313   * Remove the first matching {@link Link} item from the underlying collection.
314   * @param item the item to remove
315   * @return {@code true} if the item was removed or {@code false} otherwise
316   */
317  public boolean removeLink(Link item) {
318    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
319    return _links != null && _links.remove(value);
320  }
321
322  /**
323   * Get the "{@literal Remarks}".
324   *
325   * <p>
326   * Additional commentary about the containing object.
327   *
328   * @return the remarks value, or {@code null} if not set
329   */
330  @Nullable
331  public MarkupMultiline getRemarks() {
332    return _remarks;
333  }
334
335  /**
336   * Set the "{@literal Remarks}".
337   *
338   * <p>
339   * Additional commentary about the containing object.
340   *
341   * @param value
342   *           the remarks value to set, or {@code null} to clear
343   */
344  public void setRemarks(@Nullable MarkupMultiline value) {
345    _remarks = value;
346  }
347
348  @Override
349  public String toString() {
350    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
351  }
352}