001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
004import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
007import gov.nist.secauto.metaschema.core.model.IBoundObject;
008import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
009import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
010import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
011import gov.nist.secauto.metaschema.core.util.ObjectUtils;
012import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
013import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
014import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
015import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
016import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
017import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
018import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
019import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
020import java.lang.Override;
021import java.lang.String;
022import java.util.LinkedList;
023import java.util.List;
024import java.util.UUID;
025import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
026import org.apache.commons.lang3.builder.ToStringStyle;
027
028/**
029 * Identifies a set of assessment subjects to include/exclude by UUID.
030 */
031@MetaschemaAssembly(
032    formalName = "Select Assessment Subject",
033    description = "Identifies a set of assessment subjects to include/exclude by UUID.",
034    name = "select-subject-by-id",
035    moduleClass = OscalAssessmentCommonModule.class
036)
037public class SelectSubjectById implements IBoundObject {
038  private final IMetaschemaData __metaschemaData;
039
040  /**
041   * "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."
042   */
043  @BoundFlag(
044      formalName = "Subject Universally Unique Identifier Reference",
045      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.",
046      name = "subject-uuid",
047      required = true,
048      typeAdapter = UuidAdapter.class
049  )
050  private UUID _subjectUuid;
051
052  /**
053   * "Used to indicate the type of object pointed to by the <code>uuid-ref</code> within a subject."
054   */
055  @BoundFlag(
056      formalName = "Subject Universally Unique Identifier Reference Type",
057      description = "Used to indicate the type of object pointed to by the `uuid-ref` within a subject.",
058      name = "type",
059      required = true,
060      typeAdapter = TokenAdapter.class,
061      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(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")}))
062  )
063  private String _type;
064
065  @BoundAssembly(
066      formalName = "Property",
067      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
068      useName = "prop",
069      maxOccurs = -1,
070      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
071  )
072  private List<Property> _props;
073
074  @BoundAssembly(
075      formalName = "Link",
076      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
077      useName = "link",
078      maxOccurs = -1,
079      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
080  )
081  private List<Link> _links;
082
083  @BoundField(
084      formalName = "Remarks",
085      description = "Additional commentary about the containing object.",
086      useName = "remarks",
087      typeAdapter = MarkupMultilineAdapter.class
088  )
089  private MarkupMultiline _remarks;
090
091  public SelectSubjectById() {
092    this(null);
093  }
094
095  public SelectSubjectById(IMetaschemaData data) {
096    this.__metaschemaData = data;
097  }
098
099  @Override
100  public IMetaschemaData getMetaschemaData() {
101    return __metaschemaData;
102  }
103
104  public UUID getSubjectUuid() {
105    return _subjectUuid;
106  }
107
108  public void setSubjectUuid(UUID value) {
109    _subjectUuid = value;
110  }
111
112  public String getType() {
113    return _type;
114  }
115
116  public void setType(String value) {
117    _type = value;
118  }
119
120  public List<Property> getProps() {
121    return _props;
122  }
123
124  public void setProps(List<Property> value) {
125    _props = value;
126  }
127
128  /**
129   * Add a new {@link Property} item to the underlying collection.
130   * @param item the item to add
131   * @return {@code true}
132   */
133  public boolean addProp(Property item) {
134    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
135    if (_props == null) {
136      _props = new LinkedList<>();
137    }
138    return _props.add(value);
139  }
140
141  /**
142   * Remove the first matching {@link Property} item from the underlying collection.
143   * @param item the item to remove
144   * @return {@code true} if the item was removed or {@code false} otherwise
145   */
146  public boolean removeProp(Property item) {
147    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
148    return _props != null && _props.remove(value);
149  }
150
151  public List<Link> getLinks() {
152    return _links;
153  }
154
155  public void setLinks(List<Link> value) {
156    _links = value;
157  }
158
159  /**
160   * Add a new {@link Link} item to the underlying collection.
161   * @param item the item to add
162   * @return {@code true}
163   */
164  public boolean addLink(Link item) {
165    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
166    if (_links == null) {
167      _links = new LinkedList<>();
168    }
169    return _links.add(value);
170  }
171
172  /**
173   * Remove the first matching {@link Link} item from the underlying collection.
174   * @param item the item to remove
175   * @return {@code true} if the item was removed or {@code false} otherwise
176   */
177  public boolean removeLink(Link item) {
178    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
179    return _links != null && _links.remove(value);
180  }
181
182  public MarkupMultiline getRemarks() {
183    return _remarks;
184  }
185
186  public void setRemarks(MarkupMultiline value) {
187    _remarks = value;
188  }
189
190  @Override
191  public String toString() {
192    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
193  }
194}