Record Class OutputGuardrailConfig
- Record Components:
maxChars- character upper bound on a String return value (0 = no bound)minChars- character lower bound (0 = no bound)onFailure- disposition for a violation (never null)fallback- value substituted onFALLBACK/ degradedTRUNCATE(never null)logFailures- whether violations are logged
@OutputGuardrail (TNS-561) — lets a
builder-built Role (which has no annotation to read)
opt into output guardrails via RoleBuilder.outputGuardrail(...).
OutputGuardrailEnforcer resolves and enforces this record exactly as
it does the annotation; the annotation path adapts through from(OutputGuardrail).
Scope: this record mirrors only the runtime-enforced subset of
@OutputGuardrail (maxChars, minChars, onFailure,
fallback, logFailures). The annotation's scaffold fields
(format, schema, maxTokens, validators,
postProcessors, maskPII, piiTypes, moderateContent,
blockCategories, checkHallucination, hallucinationThreshold,
maxRetries, includeSpec) are not modelled here — they have no
runtime consumer today (note maxRetries is inert because Phase-1 RETRY
degrades to REJECT with no re-execution callback), so surfacing them on the
builder would be inert. They await the Phase-2 wiring epic, same as on the annotation.
- Since:
- 0.12.0 (TNS-561)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder; unset fields take the@OutputGuardraildefaults. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final OutputGuardrailConfigNo-guardrail sentinel — same observable effect as no@OutputGuardrailpresent. -
Constructor Summary
ConstructorsConstructorDescriptionOutputGuardrailConfig(int maxChars, int minChars, OutputGuardrail.FailureAction onFailure, String fallback, boolean logFailures) Creates an instance of aOutputGuardrailConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()static OutputGuardrailConfigdefaults()Defaults matching@OutputGuardrail's field defaults (=NONE).final booleanIndicates whether some other object is "equal to" this one.fallback()Returns the value of thefallbackrecord component.static OutputGuardrailConfigAdapts an@OutputGuardrailannotation into the config (the annotation enforcement path).final inthashCode()Returns a hash code value for this object.booleanReturns the value of thelogFailuresrecord component.intmaxChars()Returns the value of themaxCharsrecord component.intminChars()Returns the value of theminCharsrecord component.Returns the value of theonFailurerecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
NONE
No-guardrail sentinel — same observable effect as no@OutputGuardrailpresent.
-
-
Constructor Details
-
OutputGuardrailConfig
public OutputGuardrailConfig(int maxChars, int minChars, OutputGuardrail.FailureAction onFailure, String fallback, boolean logFailures) Creates an instance of aOutputGuardrailConfigrecord class.- Parameters:
maxChars- the value for themaxCharsrecord componentminChars- the value for theminCharsrecord componentonFailure- the value for theonFailurerecord componentfallback- the value for thefallbackrecord componentlogFailures- the value for thelogFailuresrecord component
-
-
Method Details
-
from
Adapts an@OutputGuardrailannotation into the config (the annotation enforcement path). -
defaults
Defaults matching@OutputGuardrail's field defaults (=NONE). -
builder
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
maxChars
public int maxChars()Returns the value of themaxCharsrecord component.- Returns:
- the value of the
maxCharsrecord component
-
minChars
public int minChars()Returns the value of theminCharsrecord component.- Returns:
- the value of the
minCharsrecord component
-
onFailure
Returns the value of theonFailurerecord component.- Returns:
- the value of the
onFailurerecord component
-
fallback
Returns the value of thefallbackrecord component.- Returns:
- the value of the
fallbackrecord component
-
logFailures
public boolean logFailures()Returns the value of thelogFailuresrecord component.- Returns:
- the value of the
logFailuresrecord component
-