ResponsibleParty.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.IndexHasKey;
import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
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.TokenAdapter;
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;

/**
 * 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.
 */
@MetaschemaAssembly(
    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.",
    name = "responsible-party",
    metaschema = OscalMetadataMetaschema.class,
    remarks = "A `responsible-party` requires one or more `party-uuid` references creating a strong relationship arc between the referenced `role-id` and the reference parties. This differs in semantics from `responsible-role` which doesn't require that a `party-uuid` is referenced.\n"
            + "\n"
            + "The scope of use of this object determines if the responsibility has been performed or will be performed in the future. The containing object will describe the intent."
)
@ValueConstraints(
    indexHasKey = @IndexHasKey(level = IConstraint.Level.ERROR, indexName = "index-metadata-role-id", keyFields = @KeyField(target = "@role-id"))
)
public class ResponsibleParty {
  @BoundFlag(
      formalName = "Responsible Role",
      description = "A reference to a `role` performed by a `party`.",
      useName = "role-id",
      required = true,
      typeAdapter = TokenAdapter.class
  )
  private String _roleId;

  /**
   * "Specifies one or more parties responsible for performing the associated <code>role</code>."
   */
  @BoundField(
      formalName = "Party Universally Unique Identifier Reference",
      description = "Specifies one or more parties responsible for performing the associated `role`.",
      useName = "party-uuid",
      minOccurs = 1,
      maxOccurs = -1
  )
  @BoundFieldValue(
      typeAdapter = UuidAdapter.class
  )
  @ValueConstraints(
      indexHasKey = @IndexHasKey(level = IConstraint.Level.ERROR, indexName = "index-metadata-party-uuid", keyFields = @KeyField)
  )
  @GroupAs(
      name = "party-uuids",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<UUID> _partyUuids;

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

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

  public ResponsibleParty() {
  }

  public String getRoleId() {
    return _roleId;
  }

  public void setRoleId(String value) {
    _roleId = value;
  }

  public List<UUID> getPartyUuids() {
    return _partyUuids;
  }

  public void setPartyUuids(List<UUID> value) {
    _partyUuids = value;
  }

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

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

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

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