Package dev.tachyonmcp.api.json.spi
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 TypeMethodDescriptionReturns the source type this factory accepts.toJsonDocument(T source) Creates a document fromsource.
-
Method Details
-
sourceType
Returns the source type this factory accepts.- Returns:
- the source type
-
toJsonDocument
Creates a document fromsource.- Parameters:
source- the source representation- Returns:
- the parsed document
- Throws:
IllegalArgumentException- ifsourceis not valid JSON
-