Class JsonApiDomainDocumentReader

java.lang.Object
com.kazforge.jsonapi.jackson3.JsonApiDomainDocumentReader

public final class JsonApiDomainDocumentReader extends Object
Reads validated JSON:API documents into an immutable JsonApiDomainDocument with flat primary DTOs and independently bound included DTOs.

Decoding and aggregate validation run exactly as in JsonApiDocumentReader: readValue(java.lang.String) overloads share its close/ownership rules and keep codec/validation failures as JsonApiDocumentReadException with the same category, pointer, location, and rule code. fromDocument(JsonApiDocument) binds only and never re-parses or re-validates.

Primary resource data and every present included element are bound through the flat binder after looking up ResourceObject.type() in the supplied ResourceTypeRegistry; identifier primary data and error documents never attempt DTO binding. Resource types absent from the registry fail with MappingDiagnostic.UNREGISTERED_RESOURCE_TYPE at the document pointer before any envelope escapes; other binder failures compose structurally with the document pointer (/data, /data/<index>, /included/<index>) per the mapping-location contract: a resource-relative binder location joins under the prefix, and a locationless binder failure reports just the prefix. Relationship properties stay linkage-only and included is never injected.

Construct instances via JsonApiJackson3.domainDocumentReader(JsonMapper, DocumentReadContext, ResourceTypeRegistry) or its overloads, never directly. Construction re-resolves every registered target against the reader's configured resource metadata and rejects keys that disagree with MappingDiagnostic.RESOURCE_TYPE_MISMATCH without a document location; missing or invalid consumer metadata reports the resolver diagnostic. The reader is safe for concurrent use once created.

  • Method Details

    • readValue

      public JsonApiDomainDocument readValue(String json)
      Decodes, validates, and binds the JSON:API document in the given string.
    • readValue

      public JsonApiDomainDocument readValue(byte[] utf8Json)
      Decodes, validates, and binds the UTF-8 JSON:API document in the given bytes.
    • readValue

      public JsonApiDomainDocument readValue(InputStream utf8Stream)
      Decodes, validates, and binds one JSON:API document from a caller-owned UTF-8 stream. The stream is not closed; only the parser created for this call is closed.
    • readValue

      public JsonApiDomainDocument readValue(tools.jackson.core.JsonParser parser)
      Decodes, validates, and binds one JSON:API document from a caller-owned parser starting at the current token (or the next token if none is current). The parser is not closed.
    • fromDocument

      public JsonApiDomainDocument fromDocument(com.kazforge.jsonapi.core.model.JsonApiDocument document)
      Binds an already-validated document into a domain envelope; never re-parses or re-validates.