Interface GuardrailService.Builder
- Enclosing interface:
GuardrailService
public static interface GuardrailService.Builder
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds and returns an instance ofGuardrailService
.default <I extends InputGuardrail>
GuardrailService.BuilderinputGuardrailClasses
(Class<? extends I>... guardrailClasses) Configures the classes of input guardrails for the Builder.<I extends InputGuardrail>
GuardrailService.BuilderinputGuardrailClasses
(List<Class<? extends I>> guardrailClasses) Configures the classes of input guardrails for the Builder.default <I extends InputGuardrail>
GuardrailService.BuilderinputGuardrails
(I... guardrails) Configures the input guardrails for the Builder.<I extends InputGuardrail>
GuardrailService.BuilderinputGuardrails
(List<I> guardrails) Sets the input guardrails for the Builder.Configures the input guardrails for the builder.default <O extends OutputGuardrail>
GuardrailService.BuilderoutputGuardrailClasses
(Class<? extends O>... guardrailClasses) Configures the classes of output guardrails for the Builder.<O extends OutputGuardrail>
GuardrailService.BuilderoutputGuardrailClasses
(List<Class<? extends O>> guardrailClasses) Configures the classes of output guardrails for the Builder.<O extends OutputGuardrail>
GuardrailService.BuilderoutputGuardrails
(List<O> guardrails) Sets the output guardrails for the Builder.default <O extends OutputGuardrail>
GuardrailService.BuilderoutputGuardrails
(O... guardrails) Configures the output guardrails for the Builder.Configures the output guardrails for the Builder.
-
Method Details
-
inputGuardrailsConfig
Configures the input guardrails for the builder.- Parameters:
config
- The configuration for input guardrails. Must not be null.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining. - Throws:
IllegalArgumentException
- ifconfig
is null.
-
outputGuardrailsConfig
Configures the output guardrails for the Builder.- Parameters:
config
- The configuration for output guardrails. Must not be null.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining. - Throws:
IllegalArgumentException
- ifconfig
is null.
-
inputGuardrailClasses
<I extends InputGuardrail> GuardrailService.Builder inputGuardrailClasses(List<Class<? extends I>> guardrailClasses) Configures the classes of input guardrails for the Builder. Existing input guardrail classes will be cleared.- Type Parameters:
I
- The type ofInputGuardrail
- Parameters:
guardrailClasses
- A list of classes implementing theInputGuardrail
interface to be used as input guardrails. May benull
.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining.
-
inputGuardrailClasses
default <I extends InputGuardrail> GuardrailService.Builder inputGuardrailClasses(Class<? extends I>... guardrailClasses) Configures the classes of input guardrails for the Builder. Existing input guardrail classes will be cleared.- Type Parameters:
I
- The type ofInputGuardrail
- Parameters:
guardrailClasses
- An array of classes implementing theInputGuardrail
interface to be used as input guardrails. May benull
.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining.
-
outputGuardrailClasses
<O extends OutputGuardrail> GuardrailService.Builder outputGuardrailClasses(List<Class<? extends O>> guardrailClasses) Configures the classes of output guardrails for the Builder. Existing output guardrail classes will be cleared.- Type Parameters:
O
- The type ofOutputGuardrail
- Parameters:
guardrailClasses
- A list of classes implementing theOutputGuardrail
interface to be used as output guardrails. May benull
.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining.
-
outputGuardrailClasses
default <O extends OutputGuardrail> GuardrailService.Builder outputGuardrailClasses(Class<? extends O>... guardrailClasses) Configures the classes of output guardrails for the Builder. Existing output guardrail classes will be cleared.- Type Parameters:
O
- The type ofOutputGuardrail
- Parameters:
guardrailClasses
- An array of classes implementing theOutputGuardrail
interface to be used as output guardrails. May benull
.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining.
-
inputGuardrails
Sets the input guardrails for the Builder. Existing input guardrails will be cleared, and the provided input guardrails will be added.- Parameters:
guardrails
- A list of input guardrails implementing theInputGuardrail
interface. Can benull
, in which case no guardrails will be added.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining.
-
inputGuardrails
Configures the input guardrails for the Builder.- Parameters:
guardrails
- An array of input guardrails implementing theInputGuardrail
interface. May benull
, in which case no guardrails will be added.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining.
-
outputGuardrails
Sets the output guardrails for the Builder. Existing output guardrails will be cleared, and the provided output guardrails will be added.- Parameters:
guardrails
- A list of output guardrails implementing theOutputGuardrail
interface. Can benull
, in which case no guardrails will be added.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining.
-
outputGuardrails
Configures the output guardrails for the Builder.- Parameters:
guardrails
- An array of output guardrails implementing theOutputGuardrail
interface. May benull
, in which case no guardrails will be added.- Returns:
- The current instance of
GuardrailService.Builder
for method chaining.
-
build
GuardrailService build()Builds and returns an instance ofGuardrailService
. This method configures input and output guardrails at the service level using the provided class-level or method-level annotations. If no method-level annotations are present, it defers to class-level annotations, and if those are absent, it uses the settings defined in the builder.- Returns:
- an instance of
GuardrailService
configured with appropriate input and output guardrails.
-