DecisionSpecScope

@ApiStatus.Experimental
class DecisionSpecScope

The receiver passed to a decisionSpec block. Each method here adds one question to the spec being built, through the matching DecisionSpec.Builder method, so a spec built with this DSL validates exactly like one built with the builder or with Questions.named(...).

Get one only as the receiver of a decisionSpec block. The DecisionSpecDsl marker stops a nested question block from reaching back into the enclosing spec scope by accident.

Functions

Link copied to clipboard
fun choice(name: String, block: ChoiceQuestionSpec.Builder.() -> Unit)

Declares a choice question. The block runs once, on a fresh ChoiceQuestionSpec.Builder that already carries the name, and must call asking(...) and add at least one option. It does not run when the name is blank or already used.

Link copied to clipboard

Declares a proposition question. The block runs once, on a fresh PropositionQuestionSpec.Builder that already carries the name, and must at least call asking(...). It does not run when the name is blank or already used.

Link copied to clipboard
fun question(question: Question<*>)

Adds a question that was built earlier, for example with Questions.named(...).

Link copied to clipboard
fun rating(name: String, block: RatingQuestionSpec.Builder.() -> Unit)

Declares a rating question. The block runs once, on a fresh RatingQuestionSpec.Builder that already carries the name, and must call asking(...) and add at least two levels, lowest first. It does not run when the name is blank or already used.