AuthorizedPrivilege.java

package gov.nist.secauto.oscal.lib.model;

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.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.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 org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * Identifies a specific system privilege held by the user, along with an associated description and/or rationale for the privilege.
 */
@MetaschemaAssembly(
    formalName = "Privilege",
    description = "Identifies a specific system privilege held by the user, along with an associated description and/or rationale for the privilege.",
    name = "authorized-privilege",
    metaschema = OscalImplementationCommonMetaschema.class
)
public class AuthorizedPrivilege {
  /**
   * "A human readable name for the privilege."
   */
  @BoundField(
      formalName = "Privilege Title",
      description = "A human readable name for the privilege.",
      useName = "title",
      minOccurs = 1
  )
  @BoundFieldValue(
      typeAdapter = MarkupLineAdapter.class
  )
  private MarkupLine _title;

  /**
   * "A summary of the privilege's purpose within the system."
   */
  @BoundField(
      formalName = "Privilege Description",
      description = "A summary of the privilege's purpose within the system.",
      useName = "description"
  )
  @BoundFieldValue(
      typeAdapter = MarkupMultilineAdapter.class
  )
  private MarkupMultiline _description;

  @BoundField(
      formalName = "Functions Performed",
      description = "Describes a function performed for a given authorized privilege by this user class.",
      useName = "function-performed",
      minOccurs = 1,
      maxOccurs = -1
  )
  @GroupAs(
      name = "functions-performed",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<String> _functionsPerformed;

  public AuthorizedPrivilege() {
  }

  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<String> getFunctionsPerformed() {
    return _functionsPerformed;
  }

  public void setFunctionsPerformed(List<String> value) {
    _functionsPerformed = value;
  }

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

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

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