Interface JsonDocumentFactory<T>

Type Parameters:
T - the source representation type
All Known Implementing Classes:
Jackson3JsonFactory, JacksonNodeJsonFactory, JacksonObjectJsonFactory

public interface JsonDocumentFactory<T>
Creates a JsonDocument from a source representation, validating it in the process.

Unlike JsonDocument.of(String), which wraps a string without inspecting it, a factory implementation parses source and rejects malformed JSON.

Discoverable via ServiceLoader: implementations register themselves in META-INF/services/dev.tachyonmcp.api.json.spi.JsonDocumentFactory, self-reporting the source type they accept through sourceType() so JsonDocument.from(Object, Class) can resolve the right provider for a given type.

Author:
Konstantin Pavlov
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the source type this factory accepts.
    toJsonDocument(T source)
    Creates a document from source.
  • Method Details

    • sourceType

      Class<T> sourceType()
      Returns the source type this factory accepts.
      Returns:
      the source type
    • toJsonDocument

      JsonDocument toJsonDocument(T source)
      Creates a document from source.
      Parameters:
      source - the source representation
      Returns:
      the parsed document
      Throws:
      IllegalArgumentException - if source is not valid JSON