001package org.schemastore.json.sarif.x210;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.UriAdapter;
004import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
005import gov.nist.secauto.metaschema.core.model.IBoundObject;
006import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
007import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
008import gov.nist.secauto.metaschema.core.util.ObjectUtils;
009import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
010import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
011import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
012import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
013import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
014import java.lang.Override;
015import java.lang.String;
016import java.net.URI;
017import java.util.LinkedList;
018import java.util.List;
019import java.util.UUID;
020import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
021import org.apache.commons.lang3.builder.ToStringStyle;
022
023@MetaschemaAssembly(
024    name = "toolComponent",
025    moduleClass = SarifModule.class
026)
027public class ToolComponent implements IBoundObject {
028  private final IMetaschemaData __metaschemaData;
029
030  /**
031   * "A stable, unique identifier for the tool component."
032   */
033  @BoundFlag(
034      formalName = "Tool Component Unique Identifier",
035      description = "A stable, unique identifier for the tool component.",
036      name = "guid",
037      typeAdapter = UuidAdapter.class
038  )
039  private UUID _guid;
040
041  @BoundField(
042      formalName = "Tool Component Name",
043      description = "The name of the tool component.",
044      useName = "name"
045  )
046  private String _name;
047
048  @BoundField(
049      formalName = "Tool Component Organization",
050      description = "The organization or company that produced the tool component.",
051      useName = "organization"
052  )
053  private String _organization;
054
055  @BoundField(
056      formalName = "Tool Component Product",
057      description = "A product suite to which the tool component belongs.",
058      useName = "product"
059  )
060  private String _product;
061
062  @BoundField(
063      formalName = "Tool Component Version",
064      description = "The tool component version, in whatever format the component natively provides.",
065      useName = "version"
066  )
067  private String _version;
068
069  @BoundField(
070      formalName = "Tool Component Semantic Version",
071      description = "The tool component version in the format specified by Semantic Versioning 2.0.",
072      useName = "semanticVersion"
073  )
074  private String _semanticVersion;
075
076  @BoundField(
077      formalName = "Tool Component Information URI",
078      description = "The absolute URI at which information about this version of the tool component can be found.",
079      useName = "informationUri",
080      typeAdapter = UriAdapter.class
081  )
082  private URI _informationUri;
083
084  @BoundAssembly(
085      formalName = "Rule",
086      description = "An array of reportingDescriptor objects relevant to the analysis performed by the tool component.",
087      useName = "rule",
088      maxOccurs = -1,
089      groupAs = @GroupAs(name = "rules", inJson = JsonGroupAsBehavior.LIST)
090  )
091  private List<ReportingDescriptor> _rules;
092
093  public ToolComponent() {
094    this(null);
095  }
096
097  public ToolComponent(IMetaschemaData data) {
098    this.__metaschemaData = data;
099  }
100
101  @Override
102  public IMetaschemaData getMetaschemaData() {
103    return __metaschemaData;
104  }
105
106  public UUID getGuid() {
107    return _guid;
108  }
109
110  public void setGuid(UUID value) {
111    _guid = value;
112  }
113
114  public String getName() {
115    return _name;
116  }
117
118  public void setName(String value) {
119    _name = value;
120  }
121
122  public String getOrganization() {
123    return _organization;
124  }
125
126  public void setOrganization(String value) {
127    _organization = value;
128  }
129
130  public String getProduct() {
131    return _product;
132  }
133
134  public void setProduct(String value) {
135    _product = value;
136  }
137
138  public String getVersion() {
139    return _version;
140  }
141
142  public void setVersion(String value) {
143    _version = value;
144  }
145
146  public String getSemanticVersion() {
147    return _semanticVersion;
148  }
149
150  public void setSemanticVersion(String value) {
151    _semanticVersion = value;
152  }
153
154  public URI getInformationUri() {
155    return _informationUri;
156  }
157
158  public void setInformationUri(URI value) {
159    _informationUri = value;
160  }
161
162  public List<ReportingDescriptor> getRules() {
163    return _rules;
164  }
165
166  public void setRules(List<ReportingDescriptor> value) {
167    _rules = value;
168  }
169
170  /**
171   * Add a new {@link ReportingDescriptor} item to the underlying collection.
172   * @param item the item to add
173   * @return {@code true}
174   */
175  public boolean addRule(ReportingDescriptor item) {
176    ReportingDescriptor value = ObjectUtils.requireNonNull(item,"item cannot be null");
177    if (_rules == null) {
178      _rules = new LinkedList<>();
179    }
180    return _rules.add(value);
181  }
182
183  /**
184   * Remove the first matching {@link ReportingDescriptor} item from the underlying collection.
185   * @param item the item to remove
186   * @return {@code true} if the item was removed or {@code false} otherwise
187   */
188  public boolean removeRule(ReportingDescriptor item) {
189    ReportingDescriptor value = ObjectUtils.requireNonNull(item,"item cannot be null");
190    return _rules != null && _rules.remove(value);
191  }
192
193  @Override
194  public String toString() {
195    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
196  }
197}