Package io.github.qishr.cascara.common.lang.type
Interface TypeSerializer
java.lang.Object
io.github.qishr.cascara.common.lang.type.TypeSerializer
All Implemented Interfaces:
TypeDescriptor
All Known Implementing Classes:
AbstractYamlTypeSerializer
public interface TypeSerializer
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public abstract AstNode | serialize(T jvmInstance) | Transforms a concrete Java object into its structural AST representation. |
| public abstract T | deserialize(AstNode astNode) | Deserializes an AST node into a strongly-typed Java object. |
| public default boolean | validate(String text, Reporter collector) | Type serializers don't need to validate, but they do everything else a type descriptor does, so we provide a default validate method here so implementations don't need to. |
Method Details
serialize
public abstract AstNode serialize(T jvmInstance)
Transforms a concrete Java object into its structural AST representation.
Parameters:
jvmInstance - The live runtime object instance to serialize.
Returns:
The matching structural AstNode graph.
Throws:
deserialize
public abstract T deserialize(AstNode astNode)
Deserializes an AST node into a strongly-typed Java object.
Parameters:
astNode - The structural AST node being parsed (e.g., YamlScalarNode, YamlMapNode).
Returns:
The fully constructed Java object instance.
Throws:
validate
public default boolean validate(String text, Reporter collector)
Type serializers don't need to validate, but they do everything else a type descriptor does, so we provide a default validate method here so implementations don't need to.
Specified By: