Package-level declarations
The problem-detail model, its builder, and the JSON codec.
| Type | Role |
|---|---|
| Problem | The document. Five standard members as properties, everything else in extensions. |
| ProblemType | A problem type — the type URI paired with the title that belongs to it. |
| ProblemValue | The value of an extension member: primitive, null, array or object. |
| problem | The builder. problem { status = 404; title = "..." }. |
| ProblemSerializer | The flattening codec, already attached to Problem. |
| ProblemException | A Problem that can be thrown. throw someType.exception(detail = "…"). |
Reading extension values is deliberately offered twice: problem.extensions["x"]?.string throws on a wrong-typed member, ?.stringOrNull returns null for it. RFC 9457 §3 requires consumers to ignore a member of an unexpected type, so *OrNull is what a conforming reader wants; the strict half exists for a caller that minted the problem type and wants a mismatch to surface.
Types
An RFC 9457 problem detail. This is the document carried by application/problem+json and application/problem+xml.
A JSON array as an extension value. Implements List<ProblemValue> by delegation, so it can be iterated and indexed directly.
Builds a Problem. Obtain one through problem, which also supplies the Json that encodes the typed payloads handed to extension and extensions. That defaults to ProblemJson unless the caller overrides it.
Scopes the builder DSL, so that a problem { } nested inside another cannot silently set members on the outer builder.
A Problem that can be thrown.
The explicit JSON null of an extension member.
A JSON object as an extension value. Implements Map<String, ProblemValue> by delegation, so members can be read with [] and iterated directly.
A scalar extension value: a string, a number, or a boolean.
A problem type carrying the three things §4 asks a type author to define: a type URI, a title, and the HTTP status code to use with it. Implementing this interface states those three once, instead of restating them at every throw site.
A value of an RFC 9457 extension member (§3.2).
Properties
The scalar parsed as a Boolean.
The scalar parsed as a Boolean, or null if this value is not a scalar or is not true/false.
The scalar parsed as a Double. Reads the wire literal, so a quoted "1.5" also returns 1.5.
The scalar parsed as a Double, or null if this value is not a scalar or does not parse.
The scalar parsed as an Int.
The scalar parsed as an Int, or null if this value is not a scalar or does not parse.
The scalar parsed as a Long. Reads the wire literal, so a quoted "30" also returns 30.
The scalar parsed as a Long, or null if this value is not a scalar or does not parse.
This value as a scalar.
This value as a scalar, or null if it is an array, an object or ProblemNull.
This value as an array.
This value as an array, or null if it is anything else.
The Json used to convert typed extension payloads when the caller supplies none. That covers the values passed to extensions(…) and extension(name, …), and the types read back by extensionsAs.
This value as an object.
This value as an object, or null if it is anything else.
The scalar's wire literal as text, with the quotes of a JSON string already removed.
The scalar's wire literal as text, or null if this value is not a scalar.
Functions
Encodes value to a standalone ProblemValue, with the serializer resolved from T.
Encodes value to a standalone ProblemValue. ProblemBuilder.extension does the same thing for one whole extension member; this is for callers building a ProblemValue that is not itself a member, such as one element of a ProblemArray.
Raises this problem type as a ProblemException.
Decodes a single extension member with the deserializer resolved from T, or returns null when the member is absent.
Adds one extension member holding an arbitrary @Serializable value, with the serializer resolved from T.
Decodes a single extension member, or returns null when it is absent.
Builds a scalar from an already-encoded wire literal.
A boolean extension value, written as the unquoted literal true or false.
A floating-point extension value.
An integer extension value.
A 64-bit integer extension value.
A string extension value. It is written quoted, so ProblemPrimitive("30") is not the number 30.