001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.model.IBoundObject;
004import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
005import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
006import gov.nist.secauto.metaschema.core.util.ObjectUtils;
007import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
008import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
009import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
010import java.lang.Override;
011import java.lang.String;
012import java.util.LinkedList;
013import java.util.List;
014import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
015import org.apache.commons.lang3.builder.ToStringStyle;
016
017/**
018 * Identifies the source of the finding, such as a tool, interviewed person, or activity.
019 */
020@MetaschemaAssembly(
021    formalName = "Origin",
022    description = "Identifies the source of the finding, such as a tool, interviewed person, or activity.",
023    name = "origin",
024    moduleClass = OscalAssessmentCommonModule.class
025)
026public class Origin implements IBoundObject {
027  private final IMetaschemaData __metaschemaData;
028
029  @BoundAssembly(
030      formalName = "Originating Actor",
031      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.",
032      useName = "actor",
033      minOccurs = 1,
034      maxOccurs = -1,
035      groupAs = @GroupAs(name = "actors", inJson = JsonGroupAsBehavior.LIST)
036  )
037  private List<OriginActor> _actors;
038
039  @BoundAssembly(
040      formalName = "Task Reference",
041      description = "Identifies an individual task for which the containing object is a consequence of.",
042      useName = "related-task",
043      maxOccurs = -1,
044      groupAs = @GroupAs(name = "related-tasks", inJson = JsonGroupAsBehavior.LIST)
045  )
046  private List<RelatedTask> _relatedTasks;
047
048  public Origin() {
049    this(null);
050  }
051
052  public Origin(IMetaschemaData data) {
053    this.__metaschemaData = data;
054  }
055
056  @Override
057  public IMetaschemaData getMetaschemaData() {
058    return __metaschemaData;
059  }
060
061  public List<OriginActor> getActors() {
062    return _actors;
063  }
064
065  public void setActors(List<OriginActor> value) {
066    _actors = value;
067  }
068
069  /**
070   * Add a new {@link OriginActor} item to the underlying collection.
071   * @param item the item to add
072   * @return {@code true}
073   */
074  public boolean addActor(OriginActor item) {
075    OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null");
076    if (_actors == null) {
077      _actors = new LinkedList<>();
078    }
079    return _actors.add(value);
080  }
081
082  /**
083   * Remove the first matching {@link OriginActor} item from the underlying collection.
084   * @param item the item to remove
085   * @return {@code true} if the item was removed or {@code false} otherwise
086   */
087  public boolean removeActor(OriginActor item) {
088    OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null");
089    return _actors != null && _actors.remove(value);
090  }
091
092  public List<RelatedTask> getRelatedTasks() {
093    return _relatedTasks;
094  }
095
096  public void setRelatedTasks(List<RelatedTask> value) {
097    _relatedTasks = value;
098  }
099
100  /**
101   * Add a new {@link RelatedTask} item to the underlying collection.
102   * @param item the item to add
103   * @return {@code true}
104   */
105  public boolean addRelatedTask(RelatedTask item) {
106    RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null");
107    if (_relatedTasks == null) {
108      _relatedTasks = new LinkedList<>();
109    }
110    return _relatedTasks.add(value);
111  }
112
113  /**
114   * Remove the first matching {@link RelatedTask} item from the underlying collection.
115   * @param item the item to remove
116   * @return {@code true} if the item was removed or {@code false} otherwise
117   */
118  public boolean removeRelatedTask(RelatedTask item) {
119    RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null");
120    return _relatedTasks != null && _relatedTasks.remove(value);
121  }
122
123  @Override
124  public String toString() {
125    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
126  }
127}