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.StringAdapter;
006import dev.metaschema.core.datatype.adapter.TokenAdapter;
007import dev.metaschema.core.datatype.markup.MarkupMultiline;
008import dev.metaschema.core.datatype.markup.MarkupMultilineAdapter;
009import dev.metaschema.core.model.IBoundObject;
010import dev.metaschema.core.model.IMetaschemaData;
011import dev.metaschema.core.model.JsonGroupAsBehavior;
012import dev.metaschema.core.model.constraint.IConstraint;
013import dev.metaschema.core.util.ObjectUtils;
014import dev.metaschema.databind.model.annotations.AllowedValue;
015import dev.metaschema.databind.model.annotations.AllowedValues;
016import dev.metaschema.databind.model.annotations.BoundAssembly;
017import dev.metaschema.databind.model.annotations.BoundField;
018import dev.metaschema.databind.model.annotations.BoundFlag;
019import dev.metaschema.databind.model.annotations.GroupAs;
020import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
021import dev.metaschema.databind.model.annotations.ValueConstraints;
022import edu.umd.cs.findbugs.annotations.NonNull;
023import edu.umd.cs.findbugs.annotations.Nullable;
024import java.util.LinkedList;
025import java.util.List;
026import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
027import org.apache.commons.lang3.builder.ToStringStyle;
028
029/**
030 * A specific edge within a source or target that is the subject of a mapping.
031 */
032@MetaschemaAssembly(
033    formalName = "Mapping Entry Item (source or target)",
034    description = "A specific edge within a source or target that is the subject of a mapping.",
035    name = "mapping-item",
036    moduleClass = OscalMappingCommonModule.class
037)
038public class MappingItem implements IBoundObject {
039  private final IMetaschemaData __metaschemaData;
040
041  /**
042   * The semantic type of the subject.
043   */
044  @BoundFlag(
045      formalName = "Subject Type",
046      description = "The semantic type of the subject.",
047      name = "type",
048      required = true,
049      typeAdapter = TokenAdapter.class,
050      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "control", description = "A control as [defined](https://pages.nist.gov/OSCAL/concepts/terminology/#control) by OSCAL."), @AllowedValue(value = "statement", description = "A textual element of a control that defines part of the control's requirements.")}))
051  )
052  private String _type;
053
054  /**
055   * A reference to an identified subject that is of the specified <code>type</code> .
056   */
057  @BoundFlag(
058      formalName = "Subject Identifier Reference",
059      description = "A reference to an identified subject that is of the specified `type` .",
060      name = "id-ref",
061      required = true,
062      typeAdapter = StringAdapter.class
063  )
064  private String _idRef;
065
066  /**
067   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
068   */
069  @BoundAssembly(
070      formalName = "Property",
071      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
072      useName = "prop",
073      maxOccurs = -1,
074      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
075  )
076  private List<Property> _props;
077
078  /**
079   * A reference to a local or remote resource, that has a specific relation to the containing object.
080   */
081  @BoundAssembly(
082      formalName = "Link",
083      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
084      useName = "link",
085      maxOccurs = -1,
086      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
087  )
088  private List<Link> _links;
089
090  /**
091   * Additional commentary about the containing object.
092   */
093  @BoundField(
094      formalName = "Remarks",
095      description = "Additional commentary about the containing object.",
096      useName = "remarks",
097      typeAdapter = MarkupMultilineAdapter.class
098  )
099  private MarkupMultiline _remarks;
100
101  /**
102   * Constructs a new {@code dev.metaschema.oscal.lib.model.MappingItem} instance with no metadata.
103   */
104  public MappingItem() {
105    this(null);
106  }
107
108  /**
109   * Constructs a new {@code dev.metaschema.oscal.lib.model.MappingItem} instance with the specified metadata.
110   *
111   * @param data
112   *           the metaschema data, or {@code null} if none
113   */
114  public MappingItem(IMetaschemaData data) {
115    this.__metaschemaData = data;
116  }
117
118  @Override
119  public IMetaschemaData getMetaschemaData() {
120    return __metaschemaData;
121  }
122
123  /**
124   * Get the "{@literal Subject Type}".
125   *
126   * <p>
127   * The semantic type of the subject.
128   *
129   * @return the type value
130   */
131  @NonNull
132  public String getType() {
133    return _type;
134  }
135
136  /**
137   * Set the "{@literal Subject Type}".
138   *
139   * <p>
140   * The semantic type of the subject.
141   *
142   * @param value
143   *           the type value to set
144   */
145  public void setType(@NonNull String value) {
146    _type = value;
147  }
148
149  /**
150   * Get the "{@literal Subject Identifier Reference}".
151   *
152   * <p>
153   * A reference to an identified subject that is of the specified <code>type</code> .
154   *
155   * @return the id-ref value
156   */
157  @NonNull
158  public String getIdRef() {
159    return _idRef;
160  }
161
162  /**
163   * Set the "{@literal Subject Identifier Reference}".
164   *
165   * <p>
166   * A reference to an identified subject that is of the specified <code>type</code> .
167   *
168   * @param value
169   *           the id-ref value to set
170   */
171  public void setIdRef(@NonNull String value) {
172    _idRef = value;
173  }
174
175  /**
176   * Get the "{@literal Property}".
177   *
178   * <p>
179   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
180   *
181   * @return the prop value
182   */
183  @NonNull
184  public List<Property> getProps() {
185    if (_props == null) {
186      _props = new LinkedList<>();
187    }
188    return ObjectUtils.notNull(_props);
189  }
190
191  /**
192   * Set the "{@literal Property}".
193   *
194   * <p>
195   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
196   *
197   * @param value
198   *           the prop value to set
199   */
200  public void setProps(@NonNull List<Property> value) {
201    _props = value;
202  }
203
204  /**
205   * Add a new {@link Property} item to the underlying collection.
206   * @param item the item to add
207   * @return {@code true}
208   */
209  public boolean addProp(Property item) {
210    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
211    if (_props == null) {
212      _props = new LinkedList<>();
213    }
214    return _props.add(value);
215  }
216
217  /**
218   * Remove the first matching {@link Property} item from the underlying collection.
219   * @param item the item to remove
220   * @return {@code true} if the item was removed or {@code false} otherwise
221   */
222  public boolean removeProp(Property item) {
223    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
224    return _props != null && _props.remove(value);
225  }
226
227  /**
228   * Get the "{@literal Link}".
229   *
230   * <p>
231   * A reference to a local or remote resource, that has a specific relation to the containing object.
232   *
233   * @return the link value
234   */
235  @NonNull
236  public List<Link> getLinks() {
237    if (_links == null) {
238      _links = new LinkedList<>();
239    }
240    return ObjectUtils.notNull(_links);
241  }
242
243  /**
244   * Set the "{@literal Link}".
245   *
246   * <p>
247   * A reference to a local or remote resource, that has a specific relation to the containing object.
248   *
249   * @param value
250   *           the link value to set
251   */
252  public void setLinks(@NonNull List<Link> value) {
253    _links = value;
254  }
255
256  /**
257   * Add a new {@link Link} item to the underlying collection.
258   * @param item the item to add
259   * @return {@code true}
260   */
261  public boolean addLink(Link item) {
262    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
263    if (_links == null) {
264      _links = new LinkedList<>();
265    }
266    return _links.add(value);
267  }
268
269  /**
270   * Remove the first matching {@link Link} item from the underlying collection.
271   * @param item the item to remove
272   * @return {@code true} if the item was removed or {@code false} otherwise
273   */
274  public boolean removeLink(Link item) {
275    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
276    return _links != null && _links.remove(value);
277  }
278
279  /**
280   * Get the "{@literal Remarks}".
281   *
282   * <p>
283   * Additional commentary about the containing object.
284   *
285   * @return the remarks value, or {@code null} if not set
286   */
287  @Nullable
288  public MarkupMultiline getRemarks() {
289    return _remarks;
290  }
291
292  /**
293   * Set the "{@literal Remarks}".
294   *
295   * <p>
296   * Additional commentary about the containing object.
297   *
298   * @param value
299   *           the remarks value to set, or {@code null} to clear
300   */
301  public void setRemarks(@Nullable MarkupMultiline value) {
302    _remarks = value;
303  }
304
305  @Override
306  public String toString() {
307    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
308  }
309}