001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_mapping-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.UriAdapter;
007import dev.metaschema.core.datatype.adapter.UriReferenceAdapter;
008import dev.metaschema.core.datatype.markup.MarkupMultiline;
009import dev.metaschema.core.datatype.markup.MarkupMultilineAdapter;
010import dev.metaschema.core.model.IBoundObject;
011import dev.metaschema.core.model.IMetaschemaData;
012import dev.metaschema.core.model.JsonGroupAsBehavior;
013import dev.metaschema.core.model.constraint.IConstraint;
014import dev.metaschema.core.util.ObjectUtils;
015import dev.metaschema.databind.model.annotations.AllowedValue;
016import dev.metaschema.databind.model.annotations.AllowedValues;
017import dev.metaschema.databind.model.annotations.BoundAssembly;
018import dev.metaschema.databind.model.annotations.BoundField;
019import dev.metaschema.databind.model.annotations.BoundFlag;
020import dev.metaschema.databind.model.annotations.GroupAs;
021import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
022import dev.metaschema.databind.model.annotations.ValueConstraints;
023import edu.umd.cs.findbugs.annotations.NonNull;
024import edu.umd.cs.findbugs.annotations.Nullable;
025import java.net.URI;
026import java.util.LinkedList;
027import java.util.List;
028import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
029import org.apache.commons.lang3.builder.ToStringStyle;
030
031/**
032 * A reference to a resource that is either the source or the target of a mapping.
033 */
034@MetaschemaAssembly(
035    formalName = "Mapped Resource Reference",
036    description = "A reference to a resource that is either the source or the target of a mapping.",
037    name = "mapping-resource-reference",
038    moduleClass = OscalMappingCommonModule.class
039)
040public class MappingResourceReference implements IBoundObject {
041  private final IMetaschemaData __metaschemaData;
042
043  /**
044   * An optional namespace qualifying the resource's <code>type</code>.
045   */
046  @BoundFlag(
047      formalName = "Resource Type Namespace",
048      description = "An optional namespace qualifying the resource's `type`.",
049      name = "ns",
050      defaultValue = "http://csrc.nist.gov/ns/oscal",
051      typeAdapter = UriAdapter.class,
052      remarks = "This value must be an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that serves as a [naming system identifier](https://pages.nist.gov/OSCAL/concepts/uri-use/#use-as-a-naming-system-identifier).\n"
053              + "\n"
054              + "When a `ns` is not provided, its value should be assumed to be `http://csrc.nist.gov/ns/oscal` and the type should be a type defined by the associated OSCAL model."
055  )
056  private URI _ns;
057
058  /**
059   * The semantic type of the resource.
060   */
061  @BoundFlag(
062      formalName = "Resource Type",
063      description = "The semantic type of the resource.",
064      name = "type",
065      required = true,
066      typeAdapter = TokenAdapter.class,
067      remarks = "The `type` value must be interpreted in the context of the associated `ns` value.\n"
068              + "\n"
069              + "When a `ns` is not provided, its value should be assumed to be `http://csrc.nist.gov/ns/oscal` and this type should be set to one of the OSCAL defined values.",
070      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "catalog", description = "The mapped resource is a control catalog."), @AllowedValue(value = "profile", description = "The mapped resource is a control profile. A resolved profile is also accepted.")}))
071  )
072  private String _type;
073
074  /**
075   * A resolvable URL reference to the base catalog or profile that this profile is tailoring.
076   */
077  @BoundFlag(
078      formalName = "Catalog or Profile Reference",
079      description = "A resolvable URL reference to the base catalog or profile that this profile is tailoring.",
080      name = "href",
081      required = true,
082      typeAdapter = UriReferenceAdapter.class,
083      remarks = "This value may be one of:\n"
084              + "\n"
085              + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n"
086              + "2. a [relative reference](https://pages.nist.gov/OSCAL/concepts/uri-use/#relative-reference) pointing to a network resolvable resource whose base URI is the URI of the containing document, or\n"
087              + "3. a bare URI fragment (i.e., \\`#uuid\\`) pointing to a `back-matter` resource in this or an imported document (see [linking to another OSCAL object](https://pages.nist.gov/OSCAL/concepts/uri-use/#linking-to-another-oscal-object))."
088  )
089  private URI _href;
090
091  /**
092   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
093   */
094  @BoundAssembly(
095      formalName = "Property",
096      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
097      useName = "prop",
098      maxOccurs = -1,
099      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
100  )
101  private List<Property> _props;
102
103  /**
104   * A reference to a local or remote resource, that has a specific relation to the containing object.
105   */
106  @BoundAssembly(
107      formalName = "Link",
108      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
109      useName = "link",
110      maxOccurs = -1,
111      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
112  )
113  private List<Link> _links;
114
115  /**
116   * Additional commentary about the containing object.
117   */
118  @BoundField(
119      formalName = "Remarks",
120      description = "Additional commentary about the containing object.",
121      useName = "remarks",
122      typeAdapter = MarkupMultilineAdapter.class
123  )
124  private MarkupMultiline _remarks;
125
126  /**
127   * Constructs a new {@code dev.metaschema.oscal.lib.model.MappingResourceReference} instance with no metadata.
128   */
129  public MappingResourceReference() {
130    this(null);
131  }
132
133  /**
134   * Constructs a new {@code dev.metaschema.oscal.lib.model.MappingResourceReference} instance with the specified metadata.
135   *
136   * @param data
137   *           the metaschema data, or {@code null} if none
138   */
139  public MappingResourceReference(IMetaschemaData data) {
140    this.__metaschemaData = data;
141  }
142
143  @Override
144  public IMetaschemaData getMetaschemaData() {
145    return __metaschemaData;
146  }
147
148  /**
149   * Get the "{@literal Resource Type Namespace}".
150   *
151   * <p>
152   * An optional namespace qualifying the resource's <code>type</code>.
153   *
154   * @return the ns value, or {@code null} if not set
155   */
156  @Nullable
157  public URI getNs() {
158    return _ns;
159  }
160
161  /**
162   * Set the "{@literal Resource Type Namespace}".
163   *
164   * <p>
165   * An optional namespace qualifying the resource's <code>type</code>.
166   *
167   * @param value
168   *           the ns value to set, or {@code null} to clear
169   */
170  public void setNs(@Nullable URI value) {
171    _ns = value;
172  }
173
174  /**
175   * Get the "{@literal Resource Type}".
176   *
177   * <p>
178   * The semantic type of the resource.
179   *
180   * @return the type value
181   */
182  @NonNull
183  public String getType() {
184    return _type;
185  }
186
187  /**
188   * Set the "{@literal Resource Type}".
189   *
190   * <p>
191   * The semantic type of the resource.
192   *
193   * @param value
194   *           the type value to set
195   */
196  public void setType(@NonNull String value) {
197    _type = value;
198  }
199
200  /**
201   * Get the "{@literal Catalog or Profile Reference}".
202   *
203   * <p>
204   * A resolvable URL reference to the base catalog or profile that this profile is tailoring.
205   *
206   * @return the href value
207   */
208  @NonNull
209  public URI getHref() {
210    return _href;
211  }
212
213  /**
214   * Set the "{@literal Catalog or Profile Reference}".
215   *
216   * <p>
217   * A resolvable URL reference to the base catalog or profile that this profile is tailoring.
218   *
219   * @param value
220   *           the href value to set
221   */
222  public void setHref(@NonNull URI value) {
223    _href = value;
224  }
225
226  /**
227   * Get the "{@literal Property}".
228   *
229   * <p>
230   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
231   *
232   * @return the prop value
233   */
234  @NonNull
235  public List<Property> getProps() {
236    if (_props == null) {
237      _props = new LinkedList<>();
238    }
239    return ObjectUtils.notNull(_props);
240  }
241
242  /**
243   * Set the "{@literal Property}".
244   *
245   * <p>
246   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
247   *
248   * @param value
249   *           the prop value to set
250   */
251  public void setProps(@NonNull List<Property> value) {
252    _props = value;
253  }
254
255  /**
256   * Add a new {@link Property} item to the underlying collection.
257   * @param item the item to add
258   * @return {@code true}
259   */
260  public boolean addProp(Property item) {
261    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
262    if (_props == null) {
263      _props = new LinkedList<>();
264    }
265    return _props.add(value);
266  }
267
268  /**
269   * Remove the first matching {@link Property} item from the underlying collection.
270   * @param item the item to remove
271   * @return {@code true} if the item was removed or {@code false} otherwise
272   */
273  public boolean removeProp(Property item) {
274    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
275    return _props != null && _props.remove(value);
276  }
277
278  /**
279   * Get the "{@literal Link}".
280   *
281   * <p>
282   * A reference to a local or remote resource, that has a specific relation to the containing object.
283   *
284   * @return the link value
285   */
286  @NonNull
287  public List<Link> getLinks() {
288    if (_links == null) {
289      _links = new LinkedList<>();
290    }
291    return ObjectUtils.notNull(_links);
292  }
293
294  /**
295   * Set the "{@literal Link}".
296   *
297   * <p>
298   * A reference to a local or remote resource, that has a specific relation to the containing object.
299   *
300   * @param value
301   *           the link value to set
302   */
303  public void setLinks(@NonNull List<Link> value) {
304    _links = value;
305  }
306
307  /**
308   * Add a new {@link Link} item to the underlying collection.
309   * @param item the item to add
310   * @return {@code true}
311   */
312  public boolean addLink(Link item) {
313    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
314    if (_links == null) {
315      _links = new LinkedList<>();
316    }
317    return _links.add(value);
318  }
319
320  /**
321   * Remove the first matching {@link Link} item from the underlying collection.
322   * @param item the item to remove
323   * @return {@code true} if the item was removed or {@code false} otherwise
324   */
325  public boolean removeLink(Link item) {
326    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
327    return _links != null && _links.remove(value);
328  }
329
330  /**
331   * Get the "{@literal Remarks}".
332   *
333   * <p>
334   * Additional commentary about the containing object.
335   *
336   * @return the remarks value, or {@code null} if not set
337   */
338  @Nullable
339  public MarkupMultiline getRemarks() {
340    return _remarks;
341  }
342
343  /**
344   * Set the "{@literal Remarks}".
345   *
346   * <p>
347   * Additional commentary about the containing object.
348   *
349   * @param value
350   *           the remarks value to set, or {@code null} to clear
351   */
352  public void setRemarks(@Nullable MarkupMultiline value) {
353    _remarks = value;
354  }
355
356  @Override
357  public String toString() {
358    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
359  }
360}