FindingTarget.java

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

import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
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.binding.model.annotations.ValueConstraints;
import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
import gov.nist.secauto.metaschema.model.common.datatype.adapter.StringAdapter;
import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
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;

/**
 * Captures an assessor's conclusions regarding the degree to which an objective is satisfied.
 */
@MetaschemaAssembly(
    formalName = "Objective Status",
    description = "Captures an assessor's conclusions regarding the degree to which an objective is satisfied.",
    name = "finding-target",
    metaschema = OscalAssessmentCommonMetaschema.class
)
public class FindingTarget {
  @BoundFlag(
      formalName = "Finding Target Type",
      description = "Identifies the type of the target.",
      useName = "type",
      required = true,
      typeAdapter = StringAdapter.class,
      remarks = "The target will always be a reference to: 1) a control statement, or 2) a control objective. In the former case, there is always a single top-level statement within a control. Thus, if the entire control is targeted, this statement identifier can be used."
  )
  @ValueConstraints(
      allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "statement-id", description = "A reference to a control statement identifier within a control."), @AllowedValue(value = "objective-id", description = "A reference to a control objective identifier within a control.")})
  )
  private String _type;

  @BoundFlag(
      formalName = "Finding Target Identifier Reference",
      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference for a specific target qualified by the `type`.",
      useName = "target-id",
      required = true,
      typeAdapter = TokenAdapter.class
  )
  private String _targetId;

  /**
   * "The title for this objective status."
   */
  @BoundField(
      formalName = "Objective Status Title",
      description = "The title for this objective status.",
      useName = "title"
  )
  @BoundFieldValue(
      typeAdapter = MarkupLineAdapter.class
  )
  private MarkupLine _title;

  /**
   * "A human-readable description of the assessor's conclusions regarding the degree to which an objective is satisfied."
   */
  @BoundField(
      formalName = "Objective Status Description",
      description = "A human-readable description of the assessor's conclusions regarding the degree to which an objective is satisfied.",
      useName = "description"
  )
  @BoundFieldValue(
      typeAdapter = MarkupMultilineAdapter.class
  )
  private MarkupMultiline _description;

  @BoundAssembly(
      formalName = "Property",
      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
      useName = "prop",
      maxOccurs = -1
  )
  @GroupAs(
      name = "props",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<Property> _props;

  @BoundAssembly(
      formalName = "Link",
      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
      useName = "link",
      maxOccurs = -1
  )
  @GroupAs(
      name = "links",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<Link> _links;

  /**
   * "A determination of if the objective is satisfied or not within a given system."
   */
  @BoundAssembly(
      formalName = "Objective Status",
      description = "A determination of if the objective is satisfied or not within a given system.",
      useName = "status",
      minOccurs = 1
  )
  private Status _status;

  @BoundAssembly(
      formalName = "Implementation Status",
      description = "Indicates the degree to which the a given control is implemented.",
      useName = "implementation-status",
      remarks = "The `implementation-status` is used to qualify the `status` value to indicate the degree to which the control was found to be implemented."
  )
  private ImplementationStatus _implementationStatus;

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

  public FindingTarget() {
  }

  public String getType() {
    return _type;
  }

  public void setType(String value) {
    _type = value;
  }

  public String getTargetId() {
    return _targetId;
  }

  public void setTargetId(String value) {
    _targetId = value;
  }

  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<Property> getProps() {
    return _props;
  }

  public void setProps(List<Property> value) {
    _props = value;
  }

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

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

  public List<Link> getLinks() {
    return _links;
  }

  public void setLinks(List<Link> value) {
    _links = value;
  }

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

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

  public Status getStatus() {
    return _status;
  }

  public void setStatus(Status value) {
    _status = value;
  }

  public ImplementationStatus getImplementationStatus() {
    return _implementationStatus;
  }

  public void setImplementationStatus(ImplementationStatus value) {
    _implementationStatus = 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();
  }

  /**
   * A determination of if the objective is satisfied or not within a given system.
   */
  @MetaschemaAssembly(
      formalName = "Objective Status",
      description = "A determination of if the objective is satisfied or not within a given system.",
      name = "status",
      metaschema = OscalAssessmentCommonMetaschema.class
  )
  public static class Status {
    @BoundFlag(
        formalName = "Objective Status State",
        description = "An indication as to whether the objective is satisfied or not.",
        useName = "state",
        required = true,
        typeAdapter = TokenAdapter.class
    )
    @ValueConstraints(
        allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "satisfied", description = "The objective has been completely satisfied."), @AllowedValue(value = "not-satisfied", description = "The objective has not been completely satisfied, but may be partially satisfied.")})
    )
    private String _state;

    @BoundFlag(
        formalName = "Objective Status Reason",
        description = "The reason the objective was given it's status.",
        useName = "reason",
        typeAdapter = TokenAdapter.class,
        remarks = "Reason may contain any value, and should be used to communicate additional information regarding the status."
    )
    @ValueConstraints(
        allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "pass", description = "The target system or system component satisfied all the conditions."), @AllowedValue(value = "fail", description = "The target system or system component did not satisfy all the conditions."), @AllowedValue(value = "other", description = "Some other event took place that is not a pass or a fail.")})
    )
    private String _reason;

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

    public Status() {
    }

    public String getState() {
      return _state;
    }

    public void setState(String value) {
      _state = value;
    }

    public String getReason() {
      return _reason;
    }

    public void setReason(String value) {
      _reason = 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();
    }
  }
}