Decision Response
The answers a model gave to a decision spec, one per question, in spec order.
A response can be read without the spec. Look an answer up by name with answer, or pass a question to the typed answer to get its outcome with the right result type. The typed lookup checks that the answer has the question's name and kind, and that its options or levels equal the question's. A question rebuilt with the same definition works. To check a whole response against a spec, for example one read back from storage, call requireMatches.
PropositionResult urgency = response.answer(urgent);
ClassificationResult team = response.answer(department);
RatingResult anger = response.answer(frustration);Build a response with builder, or record a failed request with failed. Two responses are equal when their request failures and answers are equal.
Reading a response from JSON runs the same checks as building one, answer by answer. It does not compare the response with any spec.
Types
Collects one answer per question of a spec. Get one from DecisionResponse.builder. Answers can be added in any order, and the built response lists them in spec order. A builder is not safe for use from several threads at once.
Properties
Functions
Returns the outcome for the given question, typed by the question. The question does not have to be the same object that built the response. The answer must have the question's name and kind, and a choice answer's options or a rating answer's levels must equal the question's, ids and descriptions both.
Returns the answer with the given name. Use this when the name is only known at run time, then check the answer's class or DecisionAnswer.kind to read its outcome.
Checks that this response answers the given spec. There must be one answer per question, in the spec's order, and each answer must fit its question the way the typed answer lookup requires: same name and kind, and equal options or levels.