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.model.IBoundObject;
006import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
007import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
008import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
009import gov.nist.secauto.metaschema.core.util.ObjectUtils;
010import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
011import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
012import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
013import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
014import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
015import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
016import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
017import java.lang.Override;
018import java.lang.String;
019import java.util.LinkedList;
020import java.util.List;
021import java.util.UUID;
022import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
023import org.apache.commons.lang3.builder.ToStringStyle;
024
025/**
026 * The actor that produces an observation, a finding, or a risk. One or more actor type can be used to specify a person that is using a tool.
027 */
028@MetaschemaAssembly(
029    formalName = "Originating Actor",
030    description = "The actor that produces an observation, a finding, or a risk. One or more actor type can be used to specify a person that is using a tool.",
031    name = "origin-actor",
032    moduleClass = OscalAssessmentCommonModule.class
033)
034public class OriginActor implements IBoundObject {
035  private final IMetaschemaData __metaschemaData;
036
037  /**
038   * "The kind of actor."
039   */
040  @BoundFlag(
041      formalName = "Actor Type",
042      description = "The kind of actor.",
043      name = "type",
044      required = true,
045      typeAdapter = TokenAdapter.class,
046      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "tool", description = "A reference to a tool component defined with the assessment assets."), @AllowedValue(value = "assessment-platform", description = "A reference to an assessment-platform defined with the assessment assets."), @AllowedValue(value = "party", description = "A reference to a party defined within the document metadata.")}))
047  )
048  private String _type;
049
050  /**
051   * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a> identifier reference to the tool or person based on the associated type."
052   */
053  @BoundFlag(
054      formalName = "Actor Universally Unique Identifier Reference",
055      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to the tool or person based on the associated type.",
056      name = "actor-uuid",
057      required = true,
058      typeAdapter = UuidAdapter.class
059  )
060  private UUID _actorUuid;
061
062  /**
063   * "For a party, this can optionally be used to specify the role the actor was performing."
064   */
065  @BoundFlag(
066      formalName = "Actor Role",
067      description = "For a party, this can optionally be used to specify the role the actor was performing.",
068      name = "role-id",
069      typeAdapter = TokenAdapter.class
070  )
071  private String _roleId;
072
073  @BoundAssembly(
074      formalName = "Property",
075      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
076      useName = "prop",
077      maxOccurs = -1,
078      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
079  )
080  private List<Property> _props;
081
082  @BoundAssembly(
083      formalName = "Link",
084      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
085      useName = "link",
086      maxOccurs = -1,
087      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
088  )
089  private List<Link> _links;
090
091  public OriginActor() {
092    this(null);
093  }
094
095  public OriginActor(IMetaschemaData data) {
096    this.__metaschemaData = data;
097  }
098
099  @Override
100  public IMetaschemaData getMetaschemaData() {
101    return __metaschemaData;
102  }
103
104  public String getType() {
105    return _type;
106  }
107
108  public void setType(String value) {
109    _type = value;
110  }
111
112  public UUID getActorUuid() {
113    return _actorUuid;
114  }
115
116  public void setActorUuid(UUID value) {
117    _actorUuid = value;
118  }
119
120  public String getRoleId() {
121    return _roleId;
122  }
123
124  public void setRoleId(String value) {
125    _roleId = value;
126  }
127
128  public List<Property> getProps() {
129    return _props;
130  }
131
132  public void setProps(List<Property> value) {
133    _props = value;
134  }
135
136  /**
137   * Add a new {@link Property} item to the underlying collection.
138   * @param item the item to add
139   * @return {@code true}
140   */
141  public boolean addProp(Property item) {
142    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
143    if (_props == null) {
144      _props = new LinkedList<>();
145    }
146    return _props.add(value);
147  }
148
149  /**
150   * Remove the first matching {@link Property} item from the underlying collection.
151   * @param item the item to remove
152   * @return {@code true} if the item was removed or {@code false} otherwise
153   */
154  public boolean removeProp(Property item) {
155    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
156    return _props != null && _props.remove(value);
157  }
158
159  public List<Link> getLinks() {
160    return _links;
161  }
162
163  public void setLinks(List<Link> value) {
164    _links = value;
165  }
166
167  /**
168   * Add a new {@link Link} item to the underlying collection.
169   * @param item the item to add
170   * @return {@code true}
171   */
172  public boolean addLink(Link item) {
173    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
174    if (_links == null) {
175      _links = new LinkedList<>();
176    }
177    return _links.add(value);
178  }
179
180  /**
181   * Remove the first matching {@link Link} item from the underlying collection.
182   * @param item the item to remove
183   * @return {@code true} if the item was removed or {@code false} otherwise
184   */
185  public boolean removeLink(Link item) {
186    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
187    return _links != null && _links.remove(value);
188  }
189
190  @Override
191  public String toString() {
192    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
193  }
194}