Package akka.javasdk.decision
Interface Question<A extends Answer>
- Type Parameters:
A- the type of the answer
- All Known Implementing Classes:
Question.Choice,Question.Predicate,Question.Score
public sealed interface Question<A extends Answer>
permits Question.Choice, Question.Score, Question.Predicate
A question for a decision model, see
DecisionModelClient. The type parameter is the type
of the answer.
Create a question with choice(String), score(String) or predicate(String). A question is immutable. To ask a variant of an existing question, pass it
to the factory of the same type, for example choice(Question), and build it with a new
key.
The key identifies the question and its answer, in the request and in a stored Decision. Use a short descriptive name, such as "route". All questions in one request
must have different keys.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordPick one option.static final recordA condition about the input.static final recordPlace the input on an ordered scale. -
Method Summary
Modifier and TypeMethodDescriptionstatic ChoiceBuilder.Readychoice(Question<Answer.Choice> template) Start a new choice question with the instructions and options of an existing one.static ChoiceBuilder.NoOptionsStart a question that picks one of at least two options.What the model should decide.key()The key that identifies the question and its answer.static PredicateBuilderpredicate(Question<Answer.Predicate> template) Start a new predicate question with the instructions and criteria of an existing one.static PredicateBuilderStart a question that the model answers with the probability that a condition is true.static ScoreBuilder.Readyscore(Question<Answer.Score> template) Start a new score question with the instructions and levels of an existing one.static ScoreBuilder.NoLevelsStart a question that places the input on an ordered scale of at least two levels.
-
Method Details
-
key
String key()The key that identifies the question and its answer. -
instructions
String instructions()What the model should decide. -
choice
Start a question that picks one of at least two options.- Parameters:
instructions- what the model should choose, for example "Which team should handle this ticket?"
-
choice
Start a new choice question with the instructions and options of an existing one.- Throws:
IllegalArgumentException- when the question is not a choice question
-
score
Start a question that places the input on an ordered scale of at least two levels.- Parameters:
instructions- what the model should rate, for example "How severe is the reported issue?"
-
score
Start a new score question with the instructions and levels of an existing one.- Throws:
IllegalArgumentException- when the question is not a score question
-
predicate
Start a question that the model answers with the probability that a condition is true.- Parameters:
instructions- the condition, for example "Does the customer need a reply today?"
-
predicate
Start a new predicate question with the instructions and criteria of an existing one.- Throws:
IllegalArgumentException- when the question is not a predicate question
-