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.model.IBoundObject;
006import dev.metaschema.core.model.IMetaschemaData;
007import dev.metaschema.core.model.JsonGroupAsBehavior;
008import dev.metaschema.core.util.ObjectUtils;
009import dev.metaschema.databind.model.annotations.BoundAssembly;
010import dev.metaschema.databind.model.annotations.GroupAs;
011import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
012import edu.umd.cs.findbugs.annotations.NonNull;
013import java.util.LinkedList;
014import java.util.List;
015import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
016import org.apache.commons.lang3.builder.ToStringStyle;
017
018/**
019 * Identifies the source of the finding, such as a tool, interviewed person, or activity.
020 */
021@MetaschemaAssembly(
022    formalName = "Origin",
023    description = "Identifies the source of the finding, such as a tool, interviewed person, or activity.",
024    name = "origin",
025    moduleClass = OscalAssessmentCommonModule.class
026)
027public class Origin implements IBoundObject {
028  private final IMetaschemaData __metaschemaData;
029
030  /**
031   * 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.
032   */
033  @BoundAssembly(
034      formalName = "Originating Actor",
035      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.",
036      useName = "actor",
037      minOccurs = 1,
038      maxOccurs = -1,
039      groupAs = @GroupAs(name = "actors", inJson = JsonGroupAsBehavior.LIST)
040  )
041  private List<OriginActor> _actors;
042
043  /**
044   * Identifies an individual task for which the containing object is a consequence of.
045   */
046  @BoundAssembly(
047      formalName = "Task Reference",
048      description = "Identifies an individual task for which the containing object is a consequence of.",
049      useName = "related-task",
050      maxOccurs = -1,
051      groupAs = @GroupAs(name = "related-tasks", inJson = JsonGroupAsBehavior.LIST)
052  )
053  private List<RelatedTask> _relatedTasks;
054
055  /**
056   * Constructs a new {@code dev.metaschema.oscal.lib.model.Origin} instance with no metadata.
057   */
058  public Origin() {
059    this(null);
060  }
061
062  /**
063   * Constructs a new {@code dev.metaschema.oscal.lib.model.Origin} instance with the specified metadata.
064   *
065   * @param data
066   *           the metaschema data, or {@code null} if none
067   */
068  public Origin(IMetaschemaData data) {
069    this.__metaschemaData = data;
070  }
071
072  @Override
073  public IMetaschemaData getMetaschemaData() {
074    return __metaschemaData;
075  }
076
077  /**
078   * Get the "{@literal Originating Actor}".
079   *
080   * <p>
081   * 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.
082   *
083   * @return the actor value
084   */
085  @NonNull
086  public List<OriginActor> getActors() {
087    if (_actors == null) {
088      _actors = new LinkedList<>();
089    }
090    return ObjectUtils.notNull(_actors);
091  }
092
093  /**
094   * Set the "{@literal Originating Actor}".
095   *
096   * <p>
097   * 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.
098   *
099   * @param value
100   *           the actor value to set
101   */
102  public void setActors(@NonNull List<OriginActor> value) {
103    _actors = value;
104  }
105
106  /**
107   * Add a new {@link OriginActor} item to the underlying collection.
108   * @param item the item to add
109   * @return {@code true}
110   */
111  public boolean addActor(OriginActor item) {
112    OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null");
113    if (_actors == null) {
114      _actors = new LinkedList<>();
115    }
116    return _actors.add(value);
117  }
118
119  /**
120   * Remove the first matching {@link OriginActor} item from the underlying collection.
121   * @param item the item to remove
122   * @return {@code true} if the item was removed or {@code false} otherwise
123   */
124  public boolean removeActor(OriginActor item) {
125    OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null");
126    return _actors != null && _actors.remove(value);
127  }
128
129  /**
130   * Get the "{@literal Task Reference}".
131   *
132   * <p>
133   * Identifies an individual task for which the containing object is a consequence of.
134   *
135   * @return the related-task value
136   */
137  @NonNull
138  public List<RelatedTask> getRelatedTasks() {
139    if (_relatedTasks == null) {
140      _relatedTasks = new LinkedList<>();
141    }
142    return ObjectUtils.notNull(_relatedTasks);
143  }
144
145  /**
146   * Set the "{@literal Task Reference}".
147   *
148   * <p>
149   * Identifies an individual task for which the containing object is a consequence of.
150   *
151   * @param value
152   *           the related-task value to set
153   */
154  public void setRelatedTasks(@NonNull List<RelatedTask> value) {
155    _relatedTasks = value;
156  }
157
158  /**
159   * Add a new {@link RelatedTask} item to the underlying collection.
160   * @param item the item to add
161   * @return {@code true}
162   */
163  public boolean addRelatedTask(RelatedTask item) {
164    RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null");
165    if (_relatedTasks == null) {
166      _relatedTasks = new LinkedList<>();
167    }
168    return _relatedTasks.add(value);
169  }
170
171  /**
172   * Remove the first matching {@link RelatedTask} item from the underlying collection.
173   * @param item the item to remove
174   * @return {@code true} if the item was removed or {@code false} otherwise
175   */
176  public boolean removeRelatedTask(RelatedTask item) {
177    RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null");
178    return _relatedTasks != null && _relatedTasks.remove(value);
179  }
180
181  @Override
182  public String toString() {
183    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
184  }
185}