001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
004import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
006import gov.nist.secauto.metaschema.core.model.IBoundObject;
007import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
008import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
009import gov.nist.secauto.metaschema.core.util.ObjectUtils;
010import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
011import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
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 the parameter that will be set by the enclosed value.
023 */
024@MetaschemaAssembly(
025    formalName = "Set Parameter Value",
026    description = "Identifies the parameter that will be set by the enclosed value.",
027    name = "set-parameter",
028    moduleClass = OscalImplementationCommonModule.class
029)
030public class SetParameter implements IBoundObject {
031  private final IMetaschemaData __metaschemaData;
032
033  /**
034   * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented\">human-oriented</a> reference to a <code>parameter</code> within a control, who's catalog has been imported into the current implementation context."
035   */
036  @BoundFlag(
037      formalName = "Parameter ID",
038      description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) reference to a `parameter` within a control, who's catalog has been imported into the current implementation context.",
039      name = "param-id",
040      required = true,
041      typeAdapter = TokenAdapter.class
042  )
043  private String _paramId;
044
045  @BoundField(
046      formalName = "Parameter Value",
047      description = "A parameter value or set of values.",
048      useName = "value",
049      minOccurs = 1,
050      maxOccurs = -1,
051      groupAs = @GroupAs(name = "values", inJson = JsonGroupAsBehavior.LIST)
052  )
053  private List<String> _values;
054
055  @BoundField(
056      formalName = "Remarks",
057      description = "Additional commentary about the containing object.",
058      useName = "remarks",
059      typeAdapter = MarkupMultilineAdapter.class
060  )
061  private MarkupMultiline _remarks;
062
063  public SetParameter() {
064    this(null);
065  }
066
067  public SetParameter(IMetaschemaData data) {
068    this.__metaschemaData = data;
069  }
070
071  @Override
072  public IMetaschemaData getMetaschemaData() {
073    return __metaschemaData;
074  }
075
076  public String getParamId() {
077    return _paramId;
078  }
079
080  public void setParamId(String value) {
081    _paramId = value;
082  }
083
084  public List<String> getValues() {
085    return _values;
086  }
087
088  public void setValues(List<String> value) {
089    _values = value;
090  }
091
092  /**
093   * Add a new {@link String} item to the underlying collection.
094   * @param item the item to add
095   * @return {@code true}
096   */
097  public boolean addValue(String item) {
098    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
099    if (_values == null) {
100      _values = new LinkedList<>();
101    }
102    return _values.add(value);
103  }
104
105  /**
106   * Remove the first matching {@link String} item from the underlying collection.
107   * @param item the item to remove
108   * @return {@code true} if the item was removed or {@code false} otherwise
109   */
110  public boolean removeValue(String item) {
111    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
112    return _values != null && _values.remove(value);
113  }
114
115  public MarkupMultiline getRemarks() {
116    return _remarks;
117  }
118
119  public void setRemarks(MarkupMultiline value) {
120    _remarks = value;
121  }
122
123  @Override
124  public String toString() {
125    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
126  }
127}