Finding.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.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.MetaschemaAssembly;
import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLine;
import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLineAdapter;
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;

/**
 * Describes an individual finding.
 */
@MetaschemaAssembly(
    formalName = "Finding",
    description = "Describes an individual finding.",
    name = "finding",
    metaschema = OscalAssessmentCommonMetaschema.class
)
public class Finding {
  @BoundFlag(
      formalName = "Finding Universally Unique Identifier",
      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented), [globally unique](https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique) identifier with [cross-instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance) scope that can be used to reference this finding in [this or other OSCAL instances](https://pages.nist.gov/OSCAL/concepts/identifier-use/#ar-identifiers). The locally defined *UUID* of the `finding` can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned [per-subject](https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency), which means it should be consistently used to identify the same subject across revisions of the document.",
      useName = "uuid",
      required = true,
      typeAdapter = UuidAdapter.class
  )
  private UUID _uuid;

  /**
   * "The title for this finding."
   */
  @BoundField(
      formalName = "Finding Title",
      description = "The title for this finding.",
      useName = "title",
      minOccurs = 1
  )
  @BoundFieldValue(
      typeAdapter = MarkupLineAdapter.class
  )
  private MarkupLine _title;

  /**
   * "A human-readable description of this finding."
   */
  @BoundField(
      formalName = "Finding Description",
      description = "A human-readable description of this finding.",
      useName = "description",
      minOccurs = 1
  )
  @BoundFieldValue(
      typeAdapter = MarkupMultilineAdapter.class
  )
  private MarkupMultiline _description;

  @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 = "Origin",
      description = "Identifies the source of the finding, such as a tool, interviewed person, or activity.",
      useName = "origin",
      maxOccurs = -1,
      remarks = "Used to identify the individual and/or tool generated this finding."
  )
  @GroupAs(
      name = "origins",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<Origin> _origins;

  @BoundAssembly(
      formalName = "Objective Status",
      description = "Captures an assessor's conclusions regarding the degree to which an objective is satisfied.",
      useName = "target",
      minOccurs = 1
  )
  private FindingTarget _target;

  /**
   * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a> identifier reference to the implementation statement in the SSP to which this finding is related."
   */
  @BoundField(
      formalName = "Implementation Statement UUID",
      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to the implementation statement in the SSP to which this finding is related.",
      useName = "implementation-statement-uuid"
  )
  @BoundFieldValue(
      typeAdapter = UuidAdapter.class
  )
  private UUID _implementationStatementUuid;

  /**
   * "Relates the finding to a set of referenced observations that were used to determine the finding."
   */
  @BoundAssembly(
      formalName = "Related Observation",
      description = "Relates the finding to a set of referenced observations that were used to determine the finding.",
      useName = "related-observation",
      maxOccurs = -1
  )
  @GroupAs(
      name = "related-observations",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<RelatedObservation> _relatedObservations;

  /**
   * "Relates the finding to a set of referenced risks that were used to determine the finding."
   */
  @BoundAssembly(
      formalName = "Associated Risk",
      description = "Relates the finding to a set of referenced risks that were used to determine the finding.",
      useName = "associated-risk",
      maxOccurs = -1
  )
  @GroupAs(
      name = "related-risks",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<AssociatedRisk> _relatedRisks;

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

  public Finding() {
  }

  public UUID getUuid() {
    return _uuid;
  }

  public void setUuid(UUID value) {
    _uuid = value;
  }

  public MarkupLine getTitle() {
    return _title;
  }

  public void setTitle(MarkupLine value) {
    _title = value;
  }

  public MarkupMultiline getDescription() {
    return _description;
  }

  public void setDescription(MarkupMultiline value) {
    _description = 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<Origin> getOrigins() {
    return _origins;
  }

  public void setOrigins(List<Origin> value) {
    _origins = value;
  }

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

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

  public FindingTarget getTarget() {
    return _target;
  }

  public void setTarget(FindingTarget value) {
    _target = value;
  }

  public UUID getImplementationStatementUuid() {
    return _implementationStatementUuid;
  }

  public void setImplementationStatementUuid(UUID value) {
    _implementationStatementUuid = value;
  }

  public List<RelatedObservation> getRelatedObservations() {
    return _relatedObservations;
  }

  public void setRelatedObservations(List<RelatedObservation> value) {
    _relatedObservations = value;
  }

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

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

  public List<AssociatedRisk> getRelatedRisks() {
    return _relatedRisks;
  }

  public void setRelatedRisks(List<AssociatedRisk> value) {
    _relatedRisks = value;
  }

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

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

  /**
   * Relates the finding to a set of referenced risks that were used to determine the finding.
   */
  @MetaschemaAssembly(
      formalName = "Associated Risk",
      description = "Relates the finding to a set of referenced risks that were used to determine the finding.",
      name = "associated-risk",
      metaschema = OscalAssessmentCommonMetaschema.class
  )
  public static class AssociatedRisk {
    @BoundFlag(
        formalName = "Risk Universally Unique Identifier Reference",
        description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a risk defined in the list of risks.",
        useName = "risk-uuid",
        required = true,
        typeAdapter = UuidAdapter.class
    )
    private UUID _riskUuid;

    public AssociatedRisk() {
    }

    public UUID getRiskUuid() {
      return _riskUuid;
    }

    public void setRiskUuid(UUID value) {
      _riskUuid = value;
    }

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

  /**
   * Relates the finding to a set of referenced observations that were used to determine the finding.
   */
  @MetaschemaAssembly(
      formalName = "Related Observation",
      description = "Relates the finding to a set of referenced observations that were used to determine the finding.",
      name = "related-observation",
      metaschema = OscalAssessmentCommonMetaschema.class
  )
  public static class RelatedObservation {
    @BoundFlag(
        formalName = "Observation Universally Unique Identifier Reference",
        description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to an observation defined in the list of observations.",
        useName = "observation-uuid",
        required = true,
        typeAdapter = UuidAdapter.class
    )
    private UUID _observationUuid;

    public RelatedObservation() {
    }

    public UUID getObservationUuid() {
      return _observationUuid;
    }

    public void setObservationUuid(UUID value) {
      _observationUuid = value;
    }

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