001package org.schemastore.json.sarif.x210;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.DateTimeWithTZAdapter;
004import gov.nist.secauto.metaschema.core.model.IBoundObject;
005import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
006import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
007import gov.nist.secauto.metaschema.core.util.ObjectUtils;
008import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
009import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
010import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
011import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
012import java.lang.Override;
013import java.lang.String;
014import java.time.ZonedDateTime;
015import java.util.LinkedList;
016import java.util.List;
017import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
018import org.apache.commons.lang3.builder.ToStringStyle;
019
020/**
021 * Contains information about how and when a result was detected.
022 */
023@MetaschemaAssembly(
024    formalName = "Result Provanance",
025    description = "Contains information about how and when a result was detected.",
026    name = "resultProvenance",
027    moduleClass = SarifModule.class
028)
029public class ResultProvenance implements IBoundObject {
030  private final IMetaschemaData __metaschemaData;
031
032  @BoundField(
033      formalName = "First Detection Time",
034      description = "The Coordinated Universal Time (UTC) date and time at which the result was first detected. See \\\\\"Date/time properties\\\\\" in the SARIF spec for the required format.",
035      useName = "firstDetectionTimeUtc",
036      typeAdapter = DateTimeWithTZAdapter.class
037  )
038  private ZonedDateTime _firstDetectionTimeUtc;
039
040  @BoundField(
041      formalName = "Last Detection Time",
042      description = "The Coordinated Universal Time (UTC) date and time at which the result was most recently detected. See \\\\\"Date/time properties\\\\\" in the SARIF spec for the required format.",
043      useName = "lastDetectionTimeUtc",
044      typeAdapter = DateTimeWithTZAdapter.class
045  )
046  private ZonedDateTime _lastDetectionTimeUtc;
047
048  @BoundAssembly(
049      formalName = "Conversion Source",
050      description = "An sequence of physicalLocation objects which specify the portions of an analysis tool's output that a converter transformed into the result.",
051      useName = "conversionSource",
052      maxOccurs = -1,
053      groupAs = @GroupAs(name = "conversionSources", inJson = JsonGroupAsBehavior.LIST)
054  )
055  private List<PhysicalLocation> _conversionSources;
056
057  public ResultProvenance() {
058    this(null);
059  }
060
061  public ResultProvenance(IMetaschemaData data) {
062    this.__metaschemaData = data;
063  }
064
065  @Override
066  public IMetaschemaData getMetaschemaData() {
067    return __metaschemaData;
068  }
069
070  public ZonedDateTime getFirstDetectionTimeUtc() {
071    return _firstDetectionTimeUtc;
072  }
073
074  public void setFirstDetectionTimeUtc(ZonedDateTime value) {
075    _firstDetectionTimeUtc = value;
076  }
077
078  public ZonedDateTime getLastDetectionTimeUtc() {
079    return _lastDetectionTimeUtc;
080  }
081
082  public void setLastDetectionTimeUtc(ZonedDateTime value) {
083    _lastDetectionTimeUtc = value;
084  }
085
086  public List<PhysicalLocation> getConversionSources() {
087    return _conversionSources;
088  }
089
090  public void setConversionSources(List<PhysicalLocation> value) {
091    _conversionSources = value;
092  }
093
094  /**
095   * Add a new {@link PhysicalLocation} item to the underlying collection.
096   * @param item the item to add
097   * @return {@code true}
098   */
099  public boolean addConversionSource(PhysicalLocation item) {
100    PhysicalLocation value = ObjectUtils.requireNonNull(item,"item cannot be null");
101    if (_conversionSources == null) {
102      _conversionSources = new LinkedList<>();
103    }
104    return _conversionSources.add(value);
105  }
106
107  /**
108   * Remove the first matching {@link PhysicalLocation} item from the underlying collection.
109   * @param item the item to remove
110   * @return {@code true} if the item was removed or {@code false} otherwise
111   */
112  public boolean removeConversionSource(PhysicalLocation item) {
113    PhysicalLocation value = ObjectUtils.requireNonNull(item,"item cannot be null");
114    return _conversionSources != null && _conversionSources.remove(value);
115  }
116
117  @Override
118  public String toString() {
119    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
120  }
121}