PoamItem.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.Expect;
import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
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.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 POA&M item.
 */
@MetaschemaAssembly(
    formalName = "POA&M Item",
    description = "Describes an individual POA\\&M item.",
    name = "poam-item",
    metaschema = OscalPoamMetaschema.class
)
@ValueConstraints(
    expect = @Expect(level = IConstraint.Level.WARNING, test = "@uuid", message = "It is a best practice to provide a UUID.")
)
public class PoamItem {
  @BoundFlag(
      formalName = "POA&M Item 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 [instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#instance) scope that can be used to reference this POA\\&M item entry in [this OSCAL instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#poam-identifiers). 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",
      typeAdapter = UuidAdapter.class
  )
  private UUID _uuid;

  /**
   * "The title or name for this POA&M item ."
   */
  @BoundField(
      formalName = "POA&M Item Title",
      description = "The title or name for this POA\\&M item .",
      useName = "title",
      minOccurs = 1
  )
  @BoundFieldValue(
      typeAdapter = MarkupLineAdapter.class
  )
  private MarkupLine _title;

  /**
   * "A human-readable description of POA&M item."
   */
  @BoundField(
      formalName = "POA&M Item Description",
      description = "A human-readable description of POA\\&M item.",
      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;

  /**
   * "Identifies the source of the finding, such as a tool or person."
   */
  @BoundAssembly(
      formalName = "Origin",
      description = "Identifies the source of the finding, such as a tool or person.",
      useName = "origin",
      maxOccurs = -1,
      remarks = "Used to identify the individual and/or tool generated this poam-item."
  )
  @GroupAs(
      name = "origins",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<Origin> _origins;

  /**
   * "Relates the poam-item to referenced finding(s)."
   */
  @BoundAssembly(
      formalName = "Related Finding",
      description = "Relates the poam-item to referenced finding(s).",
      useName = "related-finding",
      maxOccurs = -1
  )
  @GroupAs(
      name = "related-findings",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<RelatedFinding> _relatedFindings;

  /**
   * "Relates the poam-item to a set of referenced observations that were used to determine the finding."
   */
  @BoundAssembly(
      formalName = "Related Observation",
      description = "Relates the poam-item 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 PoamItem() {
  }

  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 List<RelatedFinding> getRelatedFindings() {
    return _relatedFindings;
  }

  public void setRelatedFindings(List<RelatedFinding> value) {
    _relatedFindings = value;
  }

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

  /**
   * Remove the first matching {@link RelatedFinding} 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 removeRelatedFinding(RelatedFinding item) {
    RelatedFinding value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _relatedFindings == null ? false : _relatedFindings.remove(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 poam-item to a set of referenced observations that were used to determine the finding.
   */
  @MetaschemaAssembly(
      formalName = "Related Observation",
      description = "Relates the poam-item to a set of referenced observations that were used to determine the finding.",
      name = "related-observation",
      metaschema = OscalPoamMetaschema.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();
    }
  }

  /**
   * Identifies the source of the finding, such as a tool or person.
   */
  @MetaschemaAssembly(
      formalName = "Origin",
      description = "Identifies the source of the finding, such as a tool or person.",
      name = "origin",
      metaschema = OscalPoamMetaschema.class,
      remarks = "Used to identify the individual and/or tool generated this poam-item."
  )
  public static 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;

    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);
    }

    @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 = OscalPoamMetaschema.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 poam-item to referenced finding(s).
   */
  @MetaschemaAssembly(
      formalName = "Related Finding",
      description = "Relates the poam-item to referenced finding(s).",
      name = "related-finding",
      metaschema = OscalPoamMetaschema.class
  )
  public static class RelatedFinding {
    @BoundFlag(
        formalName = "Finding Universally Unique Identifier Reference",
        description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a finding defined in the list of findings.",
        useName = "finding-uuid",
        required = true,
        typeAdapter = UuidAdapter.class
    )
    private UUID _findingUuid;

    public RelatedFinding() {
    }

    public UUID getFindingUuid() {
      return _findingUuid;
    }

    public void setFindingUuid(UUID value) {
      _findingUuid = value;
    }

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