Class Materializer
Document into a fully-typed document (omnist-spec ยง8).
Given a document produced by any codec and a Schema, Materializer walks
the document tree and applies type coercions where an exact-type match is not present:
integral double values are narrowed to Scalar.IntegerScalar;
integer values are widened to Scalar.NumberScalar;
and ISO-8601 strings are parsed into the appropriate temporal scalar type.
Structural violations (unexpected fields, cardinality mismatches, type mismatches) accumulate
as ValidationDiagnostic records and are thrown together as a ValidationException.
This class is stateless; all behavior is via the static materialize(dev.omnist.document.Document, dev.omnist.schema.Schema) entry point.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Documentmaterialize(Document node, Schema schema) Applies schema-driven coercion tonode, returning a fully-typedDocument.
-
Method Details
-
materialize
Applies schema-driven coercion tonode, returning a fully-typedDocument.The root of
nodeis matched againstschema.root()and then recursively against each field's declared type. Structural violations and type mismatches are accumulated and thrown together as a singleValidationExceptionat the end of the walk.- Parameters:
node- the document to coerce; typically returned by a codec'sreadmethodschema- the schema to validate and coerce against- Returns:
- the coerced document tree; structurally identical to
nodewith scalar values possibly replaced by correctly-typed instances - Throws:
ValidationException- if any cardinality, field, or type constraint is violatedRuntimeException- if nesting depth or node count exceed hard limits (200 / 1,000,000)
-