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.

  • Method Details

    • key

      String key()
      The key that identifies the question and its answer.
    • instructions

      String instructions()
      What the model should decide.
    • choice

      static ChoiceBuilder.NoOptions choice(String instructions)
      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

      static ChoiceBuilder.Ready choice(Question<Answer.Choice> template)
      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

      static ScoreBuilder.NoLevels score(String instructions)
      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

      static ScoreBuilder.Ready score(Question<Answer.Score> template)
      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

      static PredicateBuilder predicate(String instructions)
      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

      static PredicateBuilder predicate(Question<Answer.Predicate> template)
      Start a new predicate question with the instructions and criteria of an existing one.
      Throws:
      IllegalArgumentException - when the question is not a predicate question