Origin.java

package gov.nist.secauto.oscal.lib.model;

import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import java.lang.Override;
import java.lang.String;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * Identifies the source of the finding, such as a tool, interviewed person, or activity.
 */
@MetaschemaAssembly(
    formalName = "Origin",
    description = "Identifies the source of the finding, such as a tool, interviewed person, or activity.",
    name = "origin",
    metaschema = OscalAssessmentCommonMetaschema.class
)
public class Origin {
  @BoundAssembly(
      formalName = "Originating Actor",
      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.",
      useName = "actor",
      minOccurs = 1,
      maxOccurs = -1
  )
  @GroupAs(
      name = "actors",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<OriginActor> _actors;

  @BoundAssembly(
      formalName = "Task Reference",
      description = "Identifies an individual task for which the containing object is a consequence of.",
      useName = "related-task",
      maxOccurs = -1
  )
  @GroupAs(
      name = "related-tasks",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<RelatedTask> _relatedTasks;

  public Origin() {
  }

  public List<OriginActor> getActors() {
    return _actors;
  }

  public void setActors(List<OriginActor> value) {
    _actors = value;
  }

  /**
   * Add a new {@link OriginActor} item to the underlying collection.
   * @param item the item to add
   * @return {@code true}
   */
  public boolean addActor(OriginActor item) {
    OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null");
    if (_actors == null) {
      _actors = new LinkedList<>();
    }
    return _actors.add(value);
  }

  /**
   * Remove the first matching {@link OriginActor} item from the underlying collection.
   * @param item the item to remove
   * @return {@code true} if the item was removed or {@code false} otherwise
   */
  public boolean removeActor(OriginActor item) {
    OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _actors == null ? false : _actors.remove(value);
  }

  public List<RelatedTask> getRelatedTasks() {
    return _relatedTasks;
  }

  public void setRelatedTasks(List<RelatedTask> value) {
    _relatedTasks = value;
  }

  /**
   * Add a new {@link RelatedTask} item to the underlying collection.
   * @param item the item to add
   * @return {@code true}
   */
  public boolean addRelatedTask(RelatedTask item) {
    RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null");
    if (_relatedTasks == null) {
      _relatedTasks = new LinkedList<>();
    }
    return _relatedTasks.add(value);
  }

  /**
   * Remove the first matching {@link RelatedTask} item from the underlying collection.
   * @param item the item to remove
   * @return {@code true} if the item was removed or {@code false} otherwise
   */
  public boolean removeRelatedTask(RelatedTask item) {
    RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _relatedTasks == null ? false : _relatedTasks.remove(value);
  }

  @Override
  public String toString() {
    return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
  }
}