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

/**
 * Each OSCAL profile is defined by a <code>profile</code> element.
 */
@MetaschemaAssembly(
    formalName = "Profile",
    description = "Each OSCAL profile is defined by a `profile` element.",
    name = "profile",
    metaschema = OscalProfileMetaschema.class,
    rootName = "profile",
    remarks = "An OSCAL document that describes a tailoring of controls from one or more catalogs, with possible modification of multiple controls. It provides mechanisms by which controls may be selected (`import`), merged or (re)structured (`merge`), and amended (`modify`). OSCAL profiles may select subsets of controls, set parameter values for them in application, and even adjust the representation of controls as given in and by a catalog. They may also serve as sources for further modification in and by other profiles, that import them."
)
public class Profile extends AbstractOscalInstance {
  @BoundFlag(
      formalName = "Profile Universally Unique Identifier",
      description = "Provides a globally unique means to identify a given profile instance.",
      useName = "uuid",
      required = true,
      typeAdapter = UuidAdapter.class
  )
  private UUID _uuid;

  @BoundAssembly(
      formalName = "Document Metadata",
      description = "Provides information about the containing document, and defines concepts that are shared across the document.",
      useName = "metadata",
      minOccurs = 1
  )
  private Metadata _metadata;

  @BoundAssembly(
      formalName = "Import Resource",
      description = "Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.",
      useName = "import",
      minOccurs = 1,
      maxOccurs = -1
  )
  @GroupAs(
      name = "imports",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<ProfileImport> _imports;

  @BoundAssembly(
      formalName = "Merge Controls",
      description = "Provides structuring directives that instruct how controls are organized after profile resolution.",
      useName = "merge"
  )
  private Merge _merge;

  @BoundAssembly(
      formalName = "Modify Controls",
      description = "Set parameters or amend controls in resolution.",
      useName = "modify"
  )
  private Modify _modify;

  @BoundAssembly(
      formalName = "Back matter",
      description = "A collection of resources that may be referenced from within the OSCAL document instance.",
      useName = "back-matter"
  )
  private BackMatter _backMatter;

  public Profile() {
  }

  public UUID getUuid() {
    return _uuid;
  }

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

  public Metadata getMetadata() {
    return _metadata;
  }

  public void setMetadata(Metadata value) {
    _metadata = value;
  }

  public List<ProfileImport> getImports() {
    return _imports;
  }

  public void setImports(List<ProfileImport> value) {
    _imports = value;
  }

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

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

  public Merge getMerge() {
    return _merge;
  }

  public void setMerge(Merge value) {
    _merge = value;
  }

  public Modify getModify() {
    return _modify;
  }

  public void setModify(Modify value) {
    _modify = value;
  }

  public BackMatter getBackMatter() {
    return _backMatter;
  }

  public void setBackMatter(BackMatter value) {
    _backMatter = value;
  }

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