ProfileGroup.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.TokenAdapter;
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.util.ObjectUtils;
import java.lang.Override;
import java.lang.String;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * A group of (selected) controls or of groups of controls.
 */
@MetaschemaAssembly(
    formalName = "Control Group",
    description = "A group of (selected) controls or of groups of controls.",
    name = "group",
    metaschema = OscalProfileMetaschema.class,
    remarks = "This construct mirrors the same construct that exists in an OSCAL catalog."
)
public class ProfileGroup {
  @BoundFlag(
      formalName = "Group Identifier",
      description = "Identifies the group.",
      useName = "id",
      typeAdapter = TokenAdapter.class,
      remarks = "This optional data element is available to support hyperlinking to formal groups or families as defined in control catalogs, among other operations."
  )
  private String _id;

  @BoundFlag(
      formalName = "Group Class",
      description = "A textual label that provides a sub-type or characterization of the group.",
      useName = "class",
      typeAdapter = TokenAdapter.class,
      remarks = "A `class` can be used in validation rules to express extra constraints over named items of a specific `class` value.\n"
              + "\n"
              + "A `class` can also be used in an OSCAL profile as a means to target an alteration to control content."
  )
  private String _clazz;

  /**
   * "A name to be given to the group for use in display."
   */
  @BoundField(
      formalName = "Group Title",
      description = "A name to be given to the group for use in display.",
      useName = "title",
      minOccurs = 1
  )
  @BoundFieldValue(
      typeAdapter = MarkupLineAdapter.class
  )
  private MarkupLine _title;

  @BoundAssembly(
      formalName = "Parameter",
      description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
      useName = "param",
      maxOccurs = -1
  )
  @GroupAs(
      name = "params",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<Parameter> _params;

  @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 = "Part",
      description = "An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.",
      useName = "part",
      maxOccurs = -1
  )
  @GroupAs(
      name = "parts",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<ControlPart> _parts;

  @BoundAssembly(
      formalName = "Control Group",
      description = "A group of (selected) controls or of groups of controls.",
      useName = "group",
      maxOccurs = -1
  )
  @GroupAs(
      name = "groups",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<ProfileGroup> _groups;

  @BoundAssembly(
      formalName = "Insert Controls",
      description = "Specifies which controls to use in the containing context.",
      useName = "insert-controls",
      maxOccurs = -1
  )
  @GroupAs(
      name = "insert-controls",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<InsertControls> _insertControls;

  public ProfileGroup() {
  }

  public String getId() {
    return _id;
  }

  public void setId(String value) {
    _id = value;
  }

  public String getClazz() {
    return _clazz;
  }

  public void setClazz(String value) {
    _clazz = value;
  }

  public MarkupLine getTitle() {
    return _title;
  }

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

  public List<Parameter> getParams() {
    return _params;
  }

  public void setParams(List<Parameter> value) {
    _params = value;
  }

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

  /**
   * Remove the first matching {@link Parameter} 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 removeParam(Parameter item) {
    Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _params == null ? false : _params.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 List<ControlPart> getParts() {
    return _parts;
  }

  public void setParts(List<ControlPart> value) {
    _parts = value;
  }

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

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

  public List<ProfileGroup> getGroups() {
    return _groups;
  }

  public void setGroups(List<ProfileGroup> value) {
    _groups = value;
  }

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

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

  public List<InsertControls> getInsertControls() {
    return _insertControls;
  }

  public void setInsertControls(List<InsertControls> value) {
    _insertControls = value;
  }

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

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

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