SetParameter.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.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.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 the parameter that will be set by the enclosed value.
 */
@MetaschemaAssembly(
    formalName = "Set Parameter Value",
    description = "Identifies the parameter that will be set by the enclosed value.",
    name = "set-parameter",
    metaschema = OscalImplementationCommonMetaschema.class
)
public class SetParameter {
  @BoundFlag(
      formalName = "Parameter ID",
      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.",
      useName = "param-id",
      required = true,
      typeAdapter = TokenAdapter.class
  )
  private String _paramId;

  /**
   * "A parameter value or set of values."
   */
  @BoundField(
      formalName = "Parameter Value",
      description = "A parameter value or set of values.",
      useName = "value",
      minOccurs = 1,
      maxOccurs = -1
  )
  @GroupAs(
      name = "values",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<String> _values;

  @BoundField(
      formalName = "Remarks",
      description = "Additional commentary about the containing object.",
      useName = "remarks"
  )
  @BoundFieldValue(
      typeAdapter = MarkupMultilineAdapter.class
  )
  private MarkupMultiline _remarks;

  public SetParameter() {
  }

  public String getParamId() {
    return _paramId;
  }

  public void setParamId(String value) {
    _paramId = value;
  }

  public List<String> getValues() {
    return _values;
  }

  public void setValues(List<String> value) {
    _values = value;
  }

  /**
   * Add a new {@link String} item to the underlying collection.
   * @param item the item to add
   * @return {@code true}
   */
  public boolean addValue(String item) {
    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
    if (_values == null) {
      _values = new LinkedList<>();
    }
    return _values.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 removeValue(String item) {
    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _values == null ? false : _values.remove(value);
  }

  public MarkupMultiline getRemarks() {
    return _remarks;
  }

  public void setRemarks(MarkupMultiline value) {
    _remarks = value;
  }

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