DecisionResponseAssembler

@ApiStatus.Experimental
class DecisionResponseAssembler

Turns the answers a provider returned for a whole spec into a DecisionResponse. A provider reports each answer it read under the question name it mapped the answer to, and build applies the answer rules.

  • After unsafe, every question fails and the response's request failure is FailureReason.INVALID_RESPONSE.

  • A name received twice through any method fails the request the same way. A repeated name means the provider's answers cannot be matched to questions safely.

  • A name the spec does not hold is ignored and counted in the WARN line. Its siblings are kept.

  • A question with no answer, an answer of the wrong kind, an unreadable answer, or an outcome the question's validate rejects fails only that question with FailureReason.INVALID_RESPONSE.

  • The response lists the answers in spec order, whatever order they arrived in.

Outcomes pass through unchanged, so any confidence or evidence in them is what the provider reported.

When any anomaly occurs, build logs one WARN naming the service, each affected spec question with its Anomaly, and the unexpected count. Logged question names come from the spec. Received keys, ids and outcomes never appear in a log line or exception message, because a provider can be steered to echo its input there.

An assembler builds one response. It is not safe for use from several threads at once.

Types

Link copied to clipboard
@ApiStatus.Experimental
enum Anomaly : Enum<DecisionResponseAssembler.Anomaly>

What was wrong with a provider's answer, as named in the anomaly log line.

Link copied to clipboard
object Companion

Creates assemblers.

Functions

Link copied to clipboard

Returns the response the recorded answers give under the answer rules.

Link copied to clipboard

Records a choice answer.

Link copied to clipboard

Records a proposition answer.

Link copied to clipboard

Records a rating answer.

Link copied to clipboard

Records an answer whose key maps to no question.

Link copied to clipboard

Records an answer the provider could not read, as Anomaly.UNREADABLE.

Records an answer the provider could not use, with the reason.

Link copied to clipboard

Records that the response envelope is corrupt, so no answer can be matched to a question. The built response fails every question.