Record Class GuardrailResult

java.lang.Object
java.lang.Record
com.tnsai.quality.tracing.guardrail.GuardrailResult
Record Components:
passed - whether the content passed the guardrail check
score - confidence score (0.0 to 1.0)
reason - human-readable explanation of the result

public record GuardrailResult(boolean passed, double score, String reason) extends Record
Result of a guardrail evaluation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GuardrailResult(boolean passed, double score, String reason)
    Creates an instance of a GuardrailResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    fail(double score, String reason)
    Creates a failing result with a reason and confidence score.
    fail(String reason)
    Creates a failing result with a reason and full confidence.
    final int
    Returns a hash code value for this object.
    Creates a passing result with full confidence.
    pass(String reason)
    Creates a passing result with a reason.
    boolean
    Returns the value of the passed record component.
    Returns the value of the reason record component.
    double
    Returns the value of the score record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GuardrailResult

      public GuardrailResult(boolean passed, double score, String reason)
      Creates an instance of a GuardrailResult record class.
      Parameters:
      passed - the value for the passed record component
      score - the value for the score record component
      reason - the value for the reason record component
  • Method Details

    • pass

      public static GuardrailResult pass()
      Creates a passing result with full confidence.
    • pass

      public static GuardrailResult pass(String reason)
      Creates a passing result with a reason.
    • fail

      public static GuardrailResult fail(double score, String reason)
      Creates a failing result with a reason and confidence score.
    • fail

      public static GuardrailResult fail(String reason)
      Creates a failing result with a reason and full confidence.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • passed

      public boolean passed()
      Returns the value of the passed record component.
      Returns:
      the value of the passed record component
    • score

      public double score()
      Returns the value of the score record component.
      Returns:
      the value of the score record component
    • reason

      public String reason()
      Returns the value of the reason record component.
      Returns:
      the value of the reason record component