001package org.schemastore.json.sarif.x210;
002
003import gov.nist.secauto.metaschema.core.model.IBoundObject;
004import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
005import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
006import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
007import gov.nist.secauto.metaschema.core.util.ObjectUtils;
008import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
009import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
010import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
011import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
012import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
013import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
014import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
015import java.lang.Override;
016import java.lang.String;
017import java.util.LinkedList;
018import java.util.List;
019import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
020import org.apache.commons.lang3.builder.ToStringStyle;
021
022/**
023 * A standard format for the output of static analysis tools.
024 */
025@MetaschemaAssembly(
026    formalName = "Static Analysis Results Interchange Format",
027    description = "A standard format for the output of static analysis tools.",
028    name = "sarif",
029    moduleClass = SarifModule.class,
030    rootName = "sarif",
031    remarks = "Note, Metaschema does not support an anonymous top-level assembly without a key name in JSON and YAML, which is required for SARIF."
032)
033public class Sarif implements IBoundObject {
034  private final IMetaschemaData __metaschemaData;
035
036  @BoundField(
037      formalName = "SARIF Model Version",
038      description = "The version of the SARIF Model used for conforming instances.",
039      useName = "version",
040      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = @AllowedValue(value = "2.1.0", description = "")))
041  )
042  private String _version;
043
044  @BoundAssembly(
045      formalName = "Run",
046      description = "Describes a single run of an analysis tool, and contains the reported output of that run.",
047      useName = "run",
048      maxOccurs = -1,
049      groupAs = @GroupAs(name = "runs", inJson = JsonGroupAsBehavior.LIST)
050  )
051  private List<Run> _runs;
052
053  public Sarif() {
054    this(null);
055  }
056
057  public Sarif(IMetaschemaData data) {
058    this.__metaschemaData = data;
059  }
060
061  @Override
062  public IMetaschemaData getMetaschemaData() {
063    return __metaschemaData;
064  }
065
066  public String getVersion() {
067    return _version;
068  }
069
070  public void setVersion(String value) {
071    _version = value;
072  }
073
074  public List<Run> getRuns() {
075    return _runs;
076  }
077
078  public void setRuns(List<Run> value) {
079    _runs = value;
080  }
081
082  /**
083   * Add a new {@link Run} item to the underlying collection.
084   * @param item the item to add
085   * @return {@code true}
086   */
087  public boolean addRun(Run item) {
088    Run value = ObjectUtils.requireNonNull(item,"item cannot be null");
089    if (_runs == null) {
090      _runs = new LinkedList<>();
091    }
092    return _runs.add(value);
093  }
094
095  /**
096   * Remove the first matching {@link Run} item from the underlying collection.
097   * @param item the item to remove
098   * @return {@code true} if the item was removed or {@code false} otherwise
099   */
100  public boolean removeRun(Run item) {
101    Run value = ObjectUtils.requireNonNull(item,"item cannot be null");
102    return _runs != null && _runs.remove(value);
103  }
104
105  @Override
106  public String toString() {
107    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
108  }
109}