001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
004import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
007import gov.nist.secauto.metaschema.core.model.IBoundObject;
008import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
009import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
010import gov.nist.secauto.metaschema.core.util.ObjectUtils;
011import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
012import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
013import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
014import java.lang.Override;
015import java.lang.String;
016import java.util.LinkedList;
017import java.util.List;
018import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
019import org.apache.commons.lang3.builder.ToStringStyle;
020
021/**
022 * Identifies a specific system privilege held by the user, along with an associated description and/or rationale for the privilege.
023 */
024@MetaschemaAssembly(
025    formalName = "Privilege",
026    description = "Identifies a specific system privilege held by the user, along with an associated description and/or rationale for the privilege.",
027    name = "authorized-privilege",
028    moduleClass = OscalImplementationCommonModule.class
029)
030public class AuthorizedPrivilege implements IBoundObject {
031  private final IMetaschemaData __metaschemaData;
032
033  @BoundField(
034      formalName = "Privilege Title",
035      description = "A human readable name for the privilege.",
036      useName = "title",
037      minOccurs = 1,
038      typeAdapter = MarkupLineAdapter.class
039  )
040  private MarkupLine _title;
041
042  @BoundField(
043      formalName = "Privilege Description",
044      description = "A summary of the privilege's purpose within the system.",
045      useName = "description",
046      typeAdapter = MarkupMultilineAdapter.class
047  )
048  private MarkupMultiline _description;
049
050  @BoundField(
051      formalName = "Functions Performed",
052      description = "Describes a function performed for a given authorized privilege by this user class.",
053      useName = "function-performed",
054      minOccurs = 1,
055      maxOccurs = -1,
056      groupAs = @GroupAs(name = "functions-performed", inJson = JsonGroupAsBehavior.LIST)
057  )
058  private List<String> _functionsPerformed;
059
060  public AuthorizedPrivilege() {
061    this(null);
062  }
063
064  public AuthorizedPrivilege(IMetaschemaData data) {
065    this.__metaschemaData = data;
066  }
067
068  @Override
069  public IMetaschemaData getMetaschemaData() {
070    return __metaschemaData;
071  }
072
073  public MarkupLine getTitle() {
074    return _title;
075  }
076
077  public void setTitle(MarkupLine value) {
078    _title = value;
079  }
080
081  public MarkupMultiline getDescription() {
082    return _description;
083  }
084
085  public void setDescription(MarkupMultiline value) {
086    _description = value;
087  }
088
089  public List<String> getFunctionsPerformed() {
090    return _functionsPerformed;
091  }
092
093  public void setFunctionsPerformed(List<String> value) {
094    _functionsPerformed = value;
095  }
096
097  /**
098   * Add a new {@link String} item to the underlying collection.
099   * @param item the item to add
100   * @return {@code true}
101   */
102  public boolean addFunctionPerformed(String item) {
103    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
104    if (_functionsPerformed == null) {
105      _functionsPerformed = new LinkedList<>();
106    }
107    return _functionsPerformed.add(value);
108  }
109
110  /**
111   * Remove the first matching {@link String} item from the underlying collection.
112   * @param item the item to remove
113   * @return {@code true} if the item was removed or {@code false} otherwise
114   */
115  public boolean removeFunctionPerformed(String item) {
116    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
117    return _functionsPerformed != null && _functionsPerformed.remove(value);
118  }
119
120  @Override
121  public String toString() {
122    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
123  }
124}