001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_implementation-common_metaschema.xml
002// Do not edit - changes will be lost when regenerated.
003package dev.metaschema.oscal.lib.model;
004
005import dev.metaschema.core.datatype.adapter.StringAdapter;
006import dev.metaschema.core.datatype.markup.MarkupLine;
007import dev.metaschema.core.datatype.markup.MarkupLineAdapter;
008import dev.metaschema.core.datatype.markup.MarkupMultiline;
009import dev.metaschema.core.datatype.markup.MarkupMultilineAdapter;
010import dev.metaschema.core.model.IBoundObject;
011import dev.metaschema.core.model.IMetaschemaData;
012import dev.metaschema.core.model.JsonGroupAsBehavior;
013import dev.metaschema.core.util.ObjectUtils;
014import dev.metaschema.databind.model.annotations.BoundField;
015import dev.metaschema.databind.model.annotations.GroupAs;
016import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
017import edu.umd.cs.findbugs.annotations.NonNull;
018import edu.umd.cs.findbugs.annotations.Nullable;
019import java.util.LinkedList;
020import java.util.List;
021import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
022import org.apache.commons.lang3.builder.ToStringStyle;
023
024/**
025 * Identifies a specific system privilege held by the user, along with an associated description and/or rationale for the privilege.
026 */
027@MetaschemaAssembly(
028    formalName = "Privilege",
029    description = "Identifies a specific system privilege held by the user, along with an associated description and/or rationale for the privilege.",
030    name = "authorized-privilege",
031    moduleClass = OscalImplementationCommonModule.class
032)
033public class AuthorizedPrivilege implements IBoundObject {
034  private final IMetaschemaData __metaschemaData;
035
036  /**
037   * A human readable name for the privilege.
038   */
039  @BoundField(
040      formalName = "Privilege Title",
041      description = "A human readable name for the privilege.",
042      useName = "title",
043      minOccurs = 1,
044      typeAdapter = MarkupLineAdapter.class
045  )
046  private MarkupLine _title;
047
048  /**
049   * A summary of the privilege's purpose within the system.
050   */
051  @BoundField(
052      formalName = "Privilege Description",
053      description = "A summary of the privilege's purpose within the system.",
054      useName = "description",
055      typeAdapter = MarkupMultilineAdapter.class
056  )
057  private MarkupMultiline _description;
058
059  /**
060   * Describes a function performed for a given authorized privilege by this user class.
061   */
062  @BoundField(
063      formalName = "Functions Performed",
064      description = "Describes a function performed for a given authorized privilege by this user class.",
065      useName = "function-performed",
066      minOccurs = 1,
067      maxOccurs = -1,
068      groupAs = @GroupAs(name = "functions-performed", inJson = JsonGroupAsBehavior.LIST),
069      typeAdapter = StringAdapter.class
070  )
071  private List<String> _functionsPerformed;
072
073  /**
074   * Constructs a new {@code dev.metaschema.oscal.lib.model.AuthorizedPrivilege} instance with no metadata.
075   */
076  public AuthorizedPrivilege() {
077    this(null);
078  }
079
080  /**
081   * Constructs a new {@code dev.metaschema.oscal.lib.model.AuthorizedPrivilege} instance with the specified metadata.
082   *
083   * @param data
084   *           the metaschema data, or {@code null} if none
085   */
086  public AuthorizedPrivilege(IMetaschemaData data) {
087    this.__metaschemaData = data;
088  }
089
090  @Override
091  public IMetaschemaData getMetaschemaData() {
092    return __metaschemaData;
093  }
094
095  /**
096   * Get the "{@literal Privilege Title}".
097   *
098   * <p>
099   * A human readable name for the privilege.
100   *
101   * @return the title value
102   */
103  @NonNull
104  public MarkupLine getTitle() {
105    return _title;
106  }
107
108  /**
109   * Set the "{@literal Privilege Title}".
110   *
111   * <p>
112   * A human readable name for the privilege.
113   *
114   * @param value
115   *           the title value to set
116   */
117  public void setTitle(@NonNull MarkupLine value) {
118    _title = value;
119  }
120
121  /**
122   * Get the "{@literal Privilege Description}".
123   *
124   * <p>
125   * A summary of the privilege's purpose within the system.
126   *
127   * @return the description value, or {@code null} if not set
128   */
129  @Nullable
130  public MarkupMultiline getDescription() {
131    return _description;
132  }
133
134  /**
135   * Set the "{@literal Privilege Description}".
136   *
137   * <p>
138   * A summary of the privilege's purpose within the system.
139   *
140   * @param value
141   *           the description value to set, or {@code null} to clear
142   */
143  public void setDescription(@Nullable MarkupMultiline value) {
144    _description = value;
145  }
146
147  /**
148   * Get the "{@literal Functions Performed}".
149   *
150   * <p>
151   * Describes a function performed for a given authorized privilege by this user class.
152   *
153   * @return the function-performed value
154   */
155  @NonNull
156  public List<String> getFunctionsPerformed() {
157    if (_functionsPerformed == null) {
158      _functionsPerformed = new LinkedList<>();
159    }
160    return ObjectUtils.notNull(_functionsPerformed);
161  }
162
163  /**
164   * Set the "{@literal Functions Performed}".
165   *
166   * <p>
167   * Describes a function performed for a given authorized privilege by this user class.
168   *
169   * @param value
170   *           the function-performed value to set
171   */
172  public void setFunctionsPerformed(@NonNull List<String> value) {
173    _functionsPerformed = value;
174  }
175
176  /**
177   * Add a new {@link String} item to the underlying collection.
178   * @param item the item to add
179   * @return {@code true}
180   */
181  public boolean addFunctionPerformed(String item) {
182    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
183    if (_functionsPerformed == null) {
184      _functionsPerformed = new LinkedList<>();
185    }
186    return _functionsPerformed.add(value);
187  }
188
189  /**
190   * Remove the first matching {@link String} item from the underlying collection.
191   * @param item the item to remove
192   * @return {@code true} if the item was removed or {@code false} otherwise
193   */
194  public boolean removeFunctionPerformed(String item) {
195    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
196    return _functionsPerformed != null && _functionsPerformed.remove(value);
197  }
198
199  @Override
200  public String toString() {
201    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
202  }
203}