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.util.ObjectUtils;
007import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
008import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
009import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
010import java.lang.Override;
011import java.lang.String;
012import java.util.LinkedList;
013import java.util.List;
014import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
015import org.apache.commons.lang3.builder.ToStringStyle;
016
017/**
018 * Describes a single run of an analysis tool, and contains the reported output of that run.
019 */
020@MetaschemaAssembly(
021    formalName = "Run",
022    description = "Describes a single run of an analysis tool, and contains the reported output of that run.",
023    name = "run",
024    moduleClass = SarifModule.class
025)
026public class Run implements IBoundObject {
027  private final IMetaschemaData __metaschemaData;
028
029  @BoundAssembly(
030      formalName = "Tool",
031      description = "Information about the tool or tool pipeline that generated the results in this run. A run can only contain results produced by a single tool or tool pipeline. A run can aggregate results from multiple log files, as long as context around the tool run (tool command-line arguments and the like) is identical for all aggregated files.",
032      useName = "tool"
033  )
034  private Tool _tool;
035
036  @BoundAssembly(
037      formalName = "Artifact",
038      description = "A sequence of artifacts relevant to the run.",
039      useName = "artifact",
040      maxOccurs = -1,
041      groupAs = @GroupAs(name = "artifacts", inJson = JsonGroupAsBehavior.LIST)
042  )
043  private List<Artifact> _artifacts;
044
045  @BoundAssembly(
046      formalName = "Result",
047      description = "The set of results contained in an SARIF log. The results array can be omitted when a run is solely exporting rules metadata. It must be present (but may be empty) if a log file represents an actual scan.",
048      useName = "result",
049      maxOccurs = -1,
050      groupAs = @GroupAs(name = "results", inJson = JsonGroupAsBehavior.LIST)
051  )
052  private List<Result> _results;
053
054  public Run() {
055    this(null);
056  }
057
058  public Run(IMetaschemaData data) {
059    this.__metaschemaData = data;
060  }
061
062  @Override
063  public IMetaschemaData getMetaschemaData() {
064    return __metaschemaData;
065  }
066
067  public Tool getTool() {
068    return _tool;
069  }
070
071  public void setTool(Tool value) {
072    _tool = value;
073  }
074
075  public List<Artifact> getArtifacts() {
076    return _artifacts;
077  }
078
079  public void setArtifacts(List<Artifact> value) {
080    _artifacts = value;
081  }
082
083  /**
084   * Add a new {@link Artifact} item to the underlying collection.
085   * @param item the item to add
086   * @return {@code true}
087   */
088  public boolean addArtifact(Artifact item) {
089    Artifact value = ObjectUtils.requireNonNull(item,"item cannot be null");
090    if (_artifacts == null) {
091      _artifacts = new LinkedList<>();
092    }
093    return _artifacts.add(value);
094  }
095
096  /**
097   * Remove the first matching {@link Artifact} item from the underlying collection.
098   * @param item the item to remove
099   * @return {@code true} if the item was removed or {@code false} otherwise
100   */
101  public boolean removeArtifact(Artifact item) {
102    Artifact value = ObjectUtils.requireNonNull(item,"item cannot be null");
103    return _artifacts != null && _artifacts.remove(value);
104  }
105
106  public List<Result> getResults() {
107    return _results;
108  }
109
110  public void setResults(List<Result> value) {
111    _results = value;
112  }
113
114  /**
115   * Add a new {@link Result} item to the underlying collection.
116   * @param item the item to add
117   * @return {@code true}
118   */
119  public boolean addResult(Result item) {
120    Result value = ObjectUtils.requireNonNull(item,"item cannot be null");
121    if (_results == null) {
122      _results = new LinkedList<>();
123    }
124    return _results.add(value);
125  }
126
127  /**
128   * Remove the first matching {@link Result} item from the underlying collection.
129   * @param item the item to remove
130   * @return {@code true} if the item was removed or {@code false} otherwise
131   */
132  public boolean removeResult(Result item) {
133    Result value = ObjectUtils.requireNonNull(item,"item cannot be null");
134    return _results != null && _results.remove(value);
135  }
136
137  @Override
138  public String toString() {
139    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
140  }
141}