RelatedTask.java

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

import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
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 java.util.UUID;
import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * Identifies an individual task for which the containing object is a consequence of.
 */
@MetaschemaAssembly(
    formalName = "Task Reference",
    description = "Identifies an individual task for which the containing object is a consequence of.",
    name = "related-task",
    metaschema = OscalAssessmentCommonMetaschema.class
)
@AssemblyConstraints(
    isUnique = @IsUnique(id = "unique-ssp-related-task-responsible-party", level = IConstraint.Level.ERROR, target = "responsible-party", keyFields = @KeyField(target = "@role-id"), remarks = "Since `responsible-party` associates multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once.")
)
public class RelatedTask {
  @BoundFlag(
      formalName = "Task Universally Unique Identifier Reference",
      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a unique task.",
      useName = "task-uuid",
      required = true,
      typeAdapter = UuidAdapter.class
  )
  private UUID _taskUuid;

  @BoundAssembly(
      formalName = "Property",
      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
      useName = "prop",
      maxOccurs = -1
  )
  @GroupAs(
      name = "props",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<Property> _props;

  @BoundAssembly(
      formalName = "Link",
      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
      useName = "link",
      maxOccurs = -1
  )
  @GroupAs(
      name = "links",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<Link> _links;

  @BoundAssembly(
      formalName = "Responsible Party",
      description = "A reference to a set of persons and/or organizations that have responsibility for performing the referenced role in the context of the containing object.",
      useName = "responsible-party",
      maxOccurs = -1,
      remarks = "Identifies the person or organization responsible for performing a specific role defined by the activity."
  )
  @GroupAs(
      name = "responsible-parties",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<ResponsibleParty> _responsibleParties;

  @BoundAssembly(
      formalName = "Subject of Assessment",
      description = "Identifies system elements being assessed, such as components, inventory items, and locations. In the assessment plan, this identifies a planned assessment subject. In the assessment results this is an actual assessment subject, and reflects any changes from the plan. exactly what will be the focus of this assessment. Any subjects not identified in this way are out-of-scope.",
      useName = "subject",
      maxOccurs = -1,
      remarks = "The assessment subjects that the task was performed against."
  )
  @GroupAs(
      name = "subjects",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<AssessmentSubject> _subjects;

  /**
   * "Used to detail assessment subjects that were identfied by this task."
   */
  @BoundAssembly(
      formalName = "Identified Subject",
      description = "Used to detail assessment subjects that were identfied by this task.",
      useName = "identified-subject"
  )
  private IdentifiedSubject _identifiedSubject;

  @BoundField(
      formalName = "Remarks",
      description = "Additional commentary about the containing object.",
      useName = "remarks"
  )
  @BoundFieldValue(
      typeAdapter = MarkupMultilineAdapter.class
  )
  private MarkupMultiline _remarks;

  public RelatedTask() {
  }

  public UUID getTaskUuid() {
    return _taskUuid;
  }

  public void setTaskUuid(UUID value) {
    _taskUuid = value;
  }

  public List<Property> getProps() {
    return _props;
  }

  public void setProps(List<Property> value) {
    _props = value;
  }

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

  /**
   * Remove the first matching {@link Property} 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 removeProp(Property item) {
    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _props == null ? false : _props.remove(value);
  }

  public List<Link> getLinks() {
    return _links;
  }

  public void setLinks(List<Link> value) {
    _links = value;
  }

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

  /**
   * Remove the first matching {@link Link} 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 removeLink(Link item) {
    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _links == null ? false : _links.remove(value);
  }

  public List<ResponsibleParty> getResponsibleParties() {
    return _responsibleParties;
  }

  public void setResponsibleParties(List<ResponsibleParty> value) {
    _responsibleParties = value;
  }

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

  /**
   * Remove the first matching {@link ResponsibleParty} 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 removeResponsibleParty(ResponsibleParty item) {
    ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _responsibleParties == null ? false : _responsibleParties.remove(value);
  }

  public List<AssessmentSubject> getSubjects() {
    return _subjects;
  }

  public void setSubjects(List<AssessmentSubject> value) {
    _subjects = value;
  }

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

  /**
   * Remove the first matching {@link AssessmentSubject} 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 removeSubject(AssessmentSubject item) {
    AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _subjects == null ? false : _subjects.remove(value);
  }

  public IdentifiedSubject getIdentifiedSubject() {
    return _identifiedSubject;
  }

  public void setIdentifiedSubject(IdentifiedSubject value) {
    _identifiedSubject = value;
  }

  public MarkupMultiline getRemarks() {
    return _remarks;
  }

  public void setRemarks(MarkupMultiline value) {
    _remarks = value;
  }

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

  /**
   * Used to detail assessment subjects that were identfied by this task.
   */
  @MetaschemaAssembly(
      formalName = "Identified Subject",
      description = "Used to detail assessment subjects that were identfied by this task.",
      name = "identified-subject",
      metaschema = OscalAssessmentCommonMetaschema.class
  )
  public static class IdentifiedSubject {
    @BoundFlag(
        formalName = "Assessment Subject Placeholder Universally Unique Identifier Reference",
        description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a unique assessment subject placeholder defined by this task.",
        useName = "subject-placeholder-uuid",
        required = true,
        typeAdapter = UuidAdapter.class
    )
    private UUID _subjectPlaceholderUuid;

    @BoundAssembly(
        formalName = "Subject of Assessment",
        description = "Identifies system elements being assessed, such as components, inventory items, and locations. In the assessment plan, this identifies a planned assessment subject. In the assessment results this is an actual assessment subject, and reflects any changes from the plan. exactly what will be the focus of this assessment. Any subjects not identified in this way are out-of-scope.",
        useName = "subject",
        minOccurs = 1,
        maxOccurs = -1,
        remarks = "The assessment subjects that the task identified, which will be used by another task through a subject-placeholder reference. Such a task will \"consume\" these subjects."
    )
    @GroupAs(
        name = "subjects",
        inJson = JsonGroupAsBehavior.LIST
    )
    private List<AssessmentSubject> _subjects;

    public IdentifiedSubject() {
    }

    public UUID getSubjectPlaceholderUuid() {
      return _subjectPlaceholderUuid;
    }

    public void setSubjectPlaceholderUuid(UUID value) {
      _subjectPlaceholderUuid = value;
    }

    public List<AssessmentSubject> getSubjects() {
      return _subjects;
    }

    public void setSubjects(List<AssessmentSubject> value) {
      _subjects = value;
    }

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

    /**
     * Remove the first matching {@link AssessmentSubject} 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 removeSubject(AssessmentSubject item) {
      AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
      return _subjects == null ? false : _subjects.remove(value);
    }

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