Package akka.javasdk.agent.task
Class TaskTemplate<R>
Object
akka.javasdk.agent.task.TaskTemplate<R>
- Type Parameters:
R- The result type produced when the task completes.
- All Implemented Interfaces:
TaskDefinition<R>
A task definition with a parameterized instruction template. Template parameters use
{paramName} syntax and are resolved via params(Map) to produce a submittable Task.
Use define(String) to create a template, then resultConformsTo(Class) to set
the result type and instructionTemplate(String) to set the template string. Templates
are immutable and typically declared as static final constants.
At request time, resolve the template with params(Map) or override it entirely with
instructions(String).
-
Method Summary
Modifier and TypeMethodDescriptionstatic TaskTemplate<String> Define a new task template with the given name.The description of this task — what kind of work it represents.description(String description) Set the description of this task — what kind of work it represents.instructions(String instructions) Override the template with free-form instructions, returning a submittableTask.The instruction template string with{paramName}placeholders.instructionTemplate(String template) Set the instruction template with{paramName}placeholders.name()The name of this task definition — a stable identifier for the task type.Resolve the template with named parameters, returning a submittableTask.<S> TaskTemplate<S> resultConformsTo(Class<S> type) Set the expected result type.The expected result type.Rule classes that validate the result before accepting completion, or an empty list.final TaskTemplate<R> Return a new task template with the given rules.Extract parameter names from the template.
-
Method Details
-
define
Define a new task template with the given name. The name is a stable identifier for this task type. The default result type isString; callresultConformsTo(Class)to change it.- Parameters:
name- a stable identifier for this task type
-
name
Description copied from interface:TaskDefinitionThe name of this task definition — a stable identifier for the task type.- Specified by:
namein interfaceTaskDefinition<R>
-
description
Description copied from interface:TaskDefinitionThe description of this task — what kind of work it represents.- Specified by:
descriptionin interfaceTaskDefinition<R>
-
description
Set the description of this task — what kind of work it represents. -
resultType
Description copied from interface:TaskDefinitionThe expected result type.- Specified by:
resultTypein interfaceTaskDefinition<R>
-
resultConformsTo
Set the expected result type. Returns a new task template with the changed type parameter.- Type Parameters:
S- The new result type
-
instructionTemplate
Set the instruction template with{paramName}placeholders. -
instructionTemplate
The instruction template string with{paramName}placeholders. -
templateParameterNames
Extract parameter names from the template. -
ruleClasses
Rule classes that validate the result before accepting completion, or an empty list.- Specified by:
ruleClassesin interfaceTaskDefinition<R>
-
rules
@SafeVarargs public final TaskTemplate<R> rules(Class<? extends TaskRule<R>> firstRule, Class<? extends TaskRule<R>>... moreRules) Return a new task template with the given rules. Rules carry through to anyTaskproduced byparams(java.util.Map<java.lang.String, java.lang.String>)orinstructions(java.lang.String). -
params
Resolve the template with named parameters, returning a submittableTask.- Parameters:
templateParams- parameter values keyed by name- Throws:
IllegalArgumentException- if a template parameter has no value in the map
-
instructions
Override the template with free-form instructions, returning a submittableTask.
-