Record Class ExtractionResult<T>

java.lang.Object
java.lang.Record
ai.doctruth.ExtractionResult<T>
Type Parameters:
T - the extracted value's type (typically a Java record).
Record Components:
value - the extracted value.
citations - source citations keyed by field path (e.g. "partyA", "obligations[0].dueDate").
confidence - confidence scores keyed by field path.
provenance - run-level provenance (model, version, timestamps, retry count).

public record ExtractionResult<T>(T value, Map<String,Citation> citations, Map<String, Confidence> confidence, Provenance provenance) extends Record
The output of DocTruth.extract(...).run(): the extracted value plus per-field citations, per-field confidence scores, and run-level provenance.

Invariants (enforced by the compact constructor):

  • value is non-null.
  • citations and confidence are non-null (empty map allowed).
  • provenance is non-null.

Both maps are defensively copied on construction and exposed as unmodifiable views; mutating the original input map after construction does not affect the result, and calling put / remove on the accessor's return value throws UnsupportedOperationException.

Since:
0.1.0
  • Constructor Details

    • ExtractionResult

      public ExtractionResult(T value, Map<String,Citation> citations, Map<String, Confidence> confidence, Provenance provenance)
      Creates an instance of a ExtractionResult record class.
      Parameters:
      value - the value for the value record component
      citations - the value for the citations record component
      confidence - the value for the confidence record component
      provenance - the value for the provenance record component
  • Method Details

    • toAuditJson

      public String toAuditJson()
      Render this result as a W3C PROV-O JSON-LD audit document — the format auditors and compliance teams already know how to ingest. Pretty-printed; UTF-8 safe.
      Returns:
      JSON-LD string representation of the extraction's provenance graph.
    • toAuditJson

      public void toAuditJson(Path path) throws IOException
      Write toAuditJson() to path, creating parent directories if needed.
      Throws:
      NullPointerException - if path is null.
      IOException - if the file or its parents cannot be written.
    • toAuditJson

      public String toAuditJson(SignatureProvider signer)
      Render this result as audit JSON and pipe through signer for tamper-evident persistence. The default SignatureProvider.IDENTITY preserves the existing toAuditJson() bytes unchanged; custom implementations can wrap or sign the JSON before it leaves the JVM.
      Throws:
      NullPointerException - if signer is null.
    • toAuditJson

      public void toAuditJson(Path path, SignatureProvider signer) throws IOException
      Write toAuditJson(SignatureProvider) to path, creating parent directories if needed.
      Throws:
      NullPointerException - if either argument is null.
      IOException - if the file or its parents cannot be written.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • value

      public T value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • citations

      public Map<String,Citation> citations()
      Returns the value of the citations record component.
      Returns:
      the value of the citations record component
    • confidence

      public Map<String, Confidence> confidence()
      Returns the value of the confidence record component.
      Returns:
      the value of the confidence record component
    • provenance

      public Provenance provenance()
      Returns the value of the provenance record component.
      Returns:
      the value of the provenance record component