Package com.kazforge.jsonapi.jackson3
Class JsonApiDocumentWriter
java.lang.Object
com.kazforge.jsonapi.jackson3.JsonApiDocumentWriter
Validates a
JsonApiDocument against a bound ValidationContext, then writes it
with deterministic JSON:API v1.1 wire semantics.
Aggregate validation always runs before generator output starts, so validation failure cannot leave a partially written document.
Writing a MappedDocument is provenance-aware: this writer composes its bound context
with the mapping's sparse-fieldset linkage exemptions before validation, so callers never
translate mapping provenance into validation policy themselves. Every other bound setting is
preserved; an empty exemption set validates exactly like plain document writing. All output forms
share one composition path.
Caller-provided OutputStream and Writer sinks remain caller-owned and are
never closed. The caller owns the buffering and flushing lifecycle of layers it supplies.
-
Method Summary
Modifier and TypeMethodDescriptioncom.kazforge.jsonapi.core.aggregate.ValidationContextcontext()Validation context bound to this writer (before mapped-document provenance composition).voidwriteValue(OutputStream out, com.kazforge.jsonapi.core.model.JsonApiDocument document) Validatesdocumentagainst the bound context, then writes it toout.voidwriteValue(OutputStream out, com.kazforge.jsonapi.mapping.MappedDocument mapped) Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then writes it toout.voidwriteValue(Writer out, com.kazforge.jsonapi.core.model.JsonApiDocument document) Validatesdocumentagainst the bound context, then writes it toout.voidwriteValue(Writer out, com.kazforge.jsonapi.mapping.MappedDocument mapped) Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then writes it toout.voidwriteValue(tools.jackson.core.JsonGenerator generator, com.kazforge.jsonapi.core.model.JsonApiDocument document) Validatesdocumentagainst the bound context, then writes it throughgenerator.voidwriteValue(tools.jackson.core.JsonGenerator generator, com.kazforge.jsonapi.mapping.MappedDocument mapped) Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then writes it throughgenerator.byte[]writeValueAsBytes(com.kazforge.jsonapi.core.model.JsonApiDocument document) Validates a plain document against the bound context, then returns its UTF-8 JSON bytes.byte[]writeValueAsBytes(com.kazforge.jsonapi.mapping.MappedDocument mapped) Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then returns the UTF-8 JSON bytes.writeValueAsString(com.kazforge.jsonapi.core.model.JsonApiDocument document) Validates a plain document against the bound context, then returns its JSON string.writeValueAsString(com.kazforge.jsonapi.mapping.MappedDocument mapped) Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then returns the JSON string.
-
Method Details
-
context
public com.kazforge.jsonapi.core.aggregate.ValidationContext context()Validation context bound to this writer (before mapped-document provenance composition). -
writeValueAsString
Validates a plain document against the bound context, then returns its JSON string. -
writeValueAsBytes
public byte[] writeValueAsBytes(com.kazforge.jsonapi.core.model.JsonApiDocument document) Validates a plain document against the bound context, then returns its UTF-8 JSON bytes. -
writeValue
Validatesdocumentagainst the bound context, then writes it toout. The stream remains caller-owned and is not closed; the caller owns its buffering and flushing lifecycle. Only the generator created for this call is closed. -
writeValue
Validatesdocumentagainst the bound context, then writes it toout. The writer remains caller-owned and is not closed; the caller owns its buffering and flushing lifecycle. Only the generator created for this call is closed. -
writeValue
public void writeValue(tools.jackson.core.JsonGenerator generator, com.kazforge.jsonapi.core.model.JsonApiDocument document) Validatesdocumentagainst the bound context, then writes it throughgenerator. The caller owns the generator and closes it. -
writeValueAsString
Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then returns the JSON string. -
writeValueAsBytes
public byte[] writeValueAsBytes(com.kazforge.jsonapi.mapping.MappedDocument mapped) Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then returns the UTF-8 JSON bytes. -
writeValue
Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then writes it toout. The stream is not closed; it remains caller-owned, including its buffering and flushing lifecycle. Only the generator created for this call is closed. -
writeValue
Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then writes it toout. The writer is not closed; it remains caller-owned, including its buffering and flushing lifecycle. Only the generator created for this call is closed. -
writeValue
public void writeValue(tools.jackson.core.JsonGenerator generator, com.kazforge.jsonapi.mapping.MappedDocument mapped) Validatesmapped.document()against the bound context composed withmapped's sparse-fieldset linkage exemptions, then writes it throughgenerator. The caller owns the generator and closes it.
-