ToolComponent.java

package org.schemastore.json.sarif.x210;

import gov.nist.secauto.metaschema.core.datatype.adapter.UriAdapter;
import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
import gov.nist.secauto.metaschema.core.model.IBoundObject;
import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
import java.lang.Override;
import java.lang.String;
import java.net.URI;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

@MetaschemaAssembly(
    name = "toolComponent",
    moduleClass = SarifModule.class
)
public class ToolComponent implements IBoundObject {
  private final IMetaschemaData __metaschemaData;

  /**
   * "A stable, unique identifier for the tool component."
   */
  @BoundFlag(
      formalName = "Tool Component Unique Identifier",
      description = "A stable, unique identifier for the tool component.",
      name = "guid",
      typeAdapter = UuidAdapter.class
  )
  private UUID _guid;

  @BoundField(
      formalName = "Tool Component Name",
      description = "The name of the tool component.",
      useName = "name"
  )
  private String _name;

  @BoundField(
      formalName = "Tool Component Organization",
      description = "The organization or company that produced the tool component.",
      useName = "organization"
  )
  private String _organization;

  @BoundField(
      formalName = "Tool Component Product",
      description = "A product suite to which the tool component belongs.",
      useName = "product"
  )
  private String _product;

  @BoundField(
      formalName = "Tool Component Version",
      description = "The tool component version, in whatever format the component natively provides.",
      useName = "version"
  )
  private String _version;

  @BoundField(
      formalName = "Tool Component Semantic Version",
      description = "The tool component version in the format specified by Semantic Versioning 2.0.",
      useName = "semanticVersion"
  )
  private String _semanticVersion;

  @BoundField(
      formalName = "Tool Component Information URI",
      description = "The absolute URI at which information about this version of the tool component can be found.",
      useName = "informationUri",
      typeAdapter = UriAdapter.class
  )
  private URI _informationUri;

  @BoundAssembly(
      formalName = "Rule",
      description = "An array of reportingDescriptor objects relevant to the analysis performed by the tool component.",
      useName = "rule",
      maxOccurs = -1,
      groupAs = @GroupAs(name = "rules", inJson = JsonGroupAsBehavior.LIST)
  )
  private List<ReportingDescriptor> _rules;

  public ToolComponent() {
    this(null);
  }

  public ToolComponent(IMetaschemaData data) {
    this.__metaschemaData = data;
  }

  @Override
  public IMetaschemaData getMetaschemaData() {
    return __metaschemaData;
  }

  public UUID getGuid() {
    return _guid;
  }

  public void setGuid(UUID value) {
    _guid = value;
  }

  public String getName() {
    return _name;
  }

  public void setName(String value) {
    _name = value;
  }

  public String getOrganization() {
    return _organization;
  }

  public void setOrganization(String value) {
    _organization = value;
  }

  public String getProduct() {
    return _product;
  }

  public void setProduct(String value) {
    _product = value;
  }

  public String getVersion() {
    return _version;
  }

  public void setVersion(String value) {
    _version = value;
  }

  public String getSemanticVersion() {
    return _semanticVersion;
  }

  public void setSemanticVersion(String value) {
    _semanticVersion = value;
  }

  public URI getInformationUri() {
    return _informationUri;
  }

  public void setInformationUri(URI value) {
    _informationUri = value;
  }

  public List<ReportingDescriptor> getRules() {
    return _rules;
  }

  public void setRules(List<ReportingDescriptor> value) {
    _rules = value;
  }

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

  /**
   * Remove the first matching {@link ReportingDescriptor} 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 removeRule(ReportingDescriptor item) {
    ReportingDescriptor value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _rules != null && _rules.remove(value);
  }

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