Result.java
package org.schemastore.json.sarif.x210;
import gov.nist.secauto.metaschema.core.datatype.adapter.IntegerAdapter;
import gov.nist.secauto.metaschema.core.datatype.adapter.PositiveIntegerAdapter;
import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter;
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.model.constraint.IConstraint;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
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.Expect;
import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
import java.lang.Override;
import java.lang.String;
import java.math.BigInteger;
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;
/**
* Results from the run of a tool.
*/
@MetaschemaAssembly(
formalName = "Results",
description = "Results from the run of a tool.",
name = "result",
moduleClass = SarifModule.class,
valueConstraints = @ValueConstraints(expect = @Expect(level = IConstraint.Level.ERROR, test = "@ruleIndex >= -1", message = "The value '{ . }' is not greater than or equal to '-1'."))
)
public class Result implements IBoundObject {
private final IMetaschemaData __metaschemaData;
/**
* "The stable, unique identifier of the rule, if any, to which this result is relevant."
*/
@BoundFlag(
formalName = "Rule Identifier",
description = "The stable, unique identifier of the rule, if any, to which this result is relevant.",
name = "ruleId",
typeAdapter = StringAdapter.class
)
private String _ruleId;
/**
* "The stable, unique identifier of the rule, if any, to which this result is relevant."
*/
@BoundFlag(
formalName = "Rule Identifier",
description = "The stable, unique identifier of the rule, if any, to which this result is relevant.",
name = "ruleIndex",
defaultValue = "-1",
typeAdapter = IntegerAdapter.class
)
private BigInteger _ruleIndex;
/**
* "A stable, unique identifier for the result."
*/
@BoundFlag(
formalName = "Result Unique Identifier",
description = "A stable, unique identifier for the result.",
name = "guid",
typeAdapter = UuidAdapter.class
)
private UUID _guid;
@BoundAssembly(
formalName = "Reporting Descriptor Reference",
description = "A reference used to locate the rule descriptor relevant to this result.",
useName = "rule"
)
private ReportingDescriptorReference _rule;
@BoundField(
formalName = "Result Kind",
description = "A value that categorizes results by evaluation state.",
useName = "kind",
defaultValue = "fail",
valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "notApplicable", description = ""), @AllowedValue(value = "pass", description = ""), @AllowedValue(value = "fail", description = ""), @AllowedValue(value = "review", description = ""), @AllowedValue(value = "open", description = ""), @AllowedValue(value = "informational", description = "")}))
)
private String _kind;
@BoundField(
formalName = "Severity Level",
description = "A value specifying the severity level of the result.",
useName = "level",
defaultValue = "warning",
valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "none", description = ""), @AllowedValue(value = "note", description = ""), @AllowedValue(value = "warning", description = ""), @AllowedValue(value = "error", description = "")}))
)
private String _level;
@BoundAssembly(
formalName = "Result Message",
description = "A message that describes the result. The first sentence of the message only will be displayed when visible space is limited.",
useName = "message"
)
private Message _message;
@BoundAssembly(
formalName = "Scanned Artifact",
description = "Identifies the artifact that the analysis tool was instructed to scan. This need not be the same as the artifact where the result actually occurred.",
useName = "analysisTarget"
)
private ArtifactLocation _analysisTarget;
@BoundAssembly(
formalName = "Result Location",
description = "The set of locations where the result was detected. Specify only one location unless the problem indicated by the result can only be corrected by making a change at every specified location.",
useName = "location",
maxOccurs = -1,
groupAs = @GroupAs(name = "locations", inJson = JsonGroupAsBehavior.LIST)
)
private List<Location> _locations;
@BoundField(
formalName = "Occurrence Count",
description = "A positive integer specifying the number of times this logically unique result was observed in this run.",
useName = "occurenceCount",
typeAdapter = PositiveIntegerAdapter.class
)
private BigInteger _occurenceCount;
@BoundAssembly(
formalName = "Result Related Location",
description = "A set of locations relevant to this result.",
useName = "relatedLocation"
)
private Location _relatedLocation;
@BoundAssembly(
formalName = "Result Provenance",
description = "Information about how and when the result was detected.",
useName = "provenance"
)
private ResultProvenance _provenance;
public Result() {
this(null);
}
public Result(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
public String getRuleId() {
return _ruleId;
}
public void setRuleId(String value) {
_ruleId = value;
}
public BigInteger getRuleIndex() {
return _ruleIndex;
}
public void setRuleIndex(BigInteger value) {
_ruleIndex = value;
}
public UUID getGuid() {
return _guid;
}
public void setGuid(UUID value) {
_guid = value;
}
public ReportingDescriptorReference getRule() {
return _rule;
}
public void setRule(ReportingDescriptorReference value) {
_rule = value;
}
public String getKind() {
return _kind;
}
public void setKind(String value) {
_kind = value;
}
public String getLevel() {
return _level;
}
public void setLevel(String value) {
_level = value;
}
public Message getMessage() {
return _message;
}
public void setMessage(Message value) {
_message = value;
}
public ArtifactLocation getAnalysisTarget() {
return _analysisTarget;
}
public void setAnalysisTarget(ArtifactLocation value) {
_analysisTarget = value;
}
public List<Location> getLocations() {
return _locations;
}
public void setLocations(List<Location> value) {
_locations = value;
}
/**
* Add a new {@link Location} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addLocation(Location item) {
Location value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_locations == null) {
_locations = new LinkedList<>();
}
return _locations.add(value);
}
/**
* Remove the first matching {@link Location} 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 removeLocation(Location item) {
Location value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _locations != null && _locations.remove(value);
}
public BigInteger getOccurenceCount() {
return _occurenceCount;
}
public void setOccurenceCount(BigInteger value) {
_occurenceCount = value;
}
public Location getRelatedLocation() {
return _relatedLocation;
}
public void setRelatedLocation(Location value) {
_relatedLocation = value;
}
public ResultProvenance getProvenance() {
return _provenance;
}
public void setProvenance(ResultProvenance value) {
_provenance = value;
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}