AssessmentAssets.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.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;

/**
 * Identifies the assets used to perform this assessment, such as the assessment team, scanning tools, and assumptions.
 */
@MetaschemaAssembly(
    formalName = "Assessment Assets",
    description = "Identifies the assets used to perform this assessment, such as the assessment team, scanning tools, and assumptions.",
    name = "assessment-assets",
    metaschema = OscalAssessmentCommonMetaschema.class
)
@AssemblyConstraints(
    isUnique = @IsUnique(id = "unique-ssp-assessment-assets-component", level = IConstraint.Level.ERROR, target = "component", keyFields = @KeyField(target = "@uuid"), remarks = "Since multiple assessment `component` entries can be provided, each component must have a unique `uuid`.")
)
public class AssessmentAssets {
  @BoundAssembly(
      formalName = "Component",
      description = "A defined component that can be part of an implemented system.",
      useName = "component",
      maxOccurs = -1,
      remarks = "Used to add any components for tools used during the assessment. These are represented here to avoid mixing with system components.\n"
              + "\n"
              + "The technology tools used by the assessor to perform the assessment, such as vulnerability scanners. In the assessment plan these are the intended tools. In the assessment results, these are the actual tools used, including any differences from the assessment plan."
  )
  @GroupAs(
      name = "components",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<SystemComponent> _components;

  /**
   * "Used to represent the toolset used to perform aspects of the assessment."
   */
  @BoundAssembly(
      formalName = "Assessment Platform",
      description = "Used to represent the toolset used to perform aspects of the assessment.",
      useName = "assessment-platform",
      minOccurs = 1,
      maxOccurs = -1
  )
  @GroupAs(
      name = "assessment-platforms",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<AssessmentPlatform> _assessmentPlatforms;

  public AssessmentAssets() {
  }

  public List<SystemComponent> getComponents() {
    return _components;
  }

  public void setComponents(List<SystemComponent> value) {
    _components = value;
  }

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

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

  public List<AssessmentPlatform> getAssessmentPlatforms() {
    return _assessmentPlatforms;
  }

  public void setAssessmentPlatforms(List<AssessmentPlatform> value) {
    _assessmentPlatforms = value;
  }

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

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

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

  /**
   * Used to represent the toolset used to perform aspects of the assessment.
   */
  @MetaschemaAssembly(
      formalName = "Assessment Platform",
      description = "Used to represent the toolset used to perform aspects of the assessment.",
      name = "assessment-platform",
      metaschema = OscalAssessmentCommonMetaschema.class
  )
  public static class AssessmentPlatform {
    @BoundFlag(
        formalName = "Assessment Platform 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 assessment platform elsewhere in this or other OSCAL instances. The locally defined *UUID* of the `assessment platform` can be used to reference the data item locally or globally (e.g., in an [imported OSCAL instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#scope)). 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 or name for the assessment platform."
     */
    @BoundField(
        formalName = "Assessment Platform Title",
        description = "The title or name for the assessment platform.",
        useName = "title"
    )
    @BoundFieldValue(
        typeAdapter = MarkupLineAdapter.class
    )
    private MarkupLine _title;

    @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;

    /**
     * "The set of components that are used by the assessment platform."
     */
    @BoundAssembly(
        formalName = "Uses Component",
        description = "The set of components that are used by the assessment platform.",
        useName = "uses-component",
        maxOccurs = -1
    )
    @GroupAs(
        name = "uses-components",
        inJson = JsonGroupAsBehavior.LIST
    )
    private List<UsesComponent> _usesComponents;

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

    public AssessmentPlatform() {
    }

    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 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<UsesComponent> getUsesComponents() {
      return _usesComponents;
    }

    public void setUsesComponents(List<UsesComponent> value) {
      _usesComponents = value;
    }

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

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

    /**
     * The set of components that are used by the assessment platform.
     */
    @MetaschemaAssembly(
        formalName = "Uses Component",
        description = "The set of components that are used by the assessment platform.",
        name = "uses-component",
        metaschema = OscalAssessmentCommonMetaschema.class
    )
    @AssemblyConstraints(
        isUnique = @IsUnique(id = "unique-ssp-uses-component-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 static class UsesComponent {
      @BoundFlag(
          formalName = "Component Universally Unique Identifier Reference",
          description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a component that is implemented as part of an inventory item.",
          useName = "component-uuid",
          required = true,
          typeAdapter = UuidAdapter.class
      )
      private UUID _componentUuid;

      @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
      )
      @GroupAs(
          name = "responsible-parties",
          inJson = JsonGroupAsBehavior.LIST
      )
      private List<ResponsibleParty> _responsibleParties;

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

      public UsesComponent() {
      }

      public UUID getComponentUuid() {
        return _componentUuid;
      }

      public void setComponentUuid(UUID value) {
        _componentUuid = 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 MarkupMultiline getRemarks() {
        return _remarks;
      }

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

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