Package io.github.qishr.cascara.common.lang.processor
Interface Serializer
java.lang.Object
io.github.qishr.cascara.common.lang.processor.Serializer
All Implemented Interfaces:
Processor
All Known Implementing Classes:
YamlSerializer
public interface Serializer
Handles the transformation between Java Objects (POJOs) and the AST or textual formats.This interface provides a high-level API for data binding, allowing users to move seamlessly between raw objects, structured ASTs, and the final string output.
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public abstract String | toText(Object object) | |
| public abstract C | fromText(String text, Class |
|
| public abstract A | toAst(Object object) | Transforms a Java Object into an AST representation. |
| public abstract C | fromAst(A astNode, Class |
Transforms an AST representation back into a specific Java type. |
Method Details
toText
public abstract String toText(Object object)
Parameters:
object - The object to serialize.
Returns:
The formatted string (e.g., YAML or JSON).
Throws:
fromText
public abstract C fromText(String text, Class
Parameters:
text - The source text to parse and deserialize.
clazz - The target type.
Returns:
A populated instance of the requested class.
Throws:
toAst
public abstract A toAst(Object object)
Transforms a Java Object into an AST representation.
Parameters:
object - The POJO or collection to transform.
Returns:
An AST representation of the provided object.
fromAst
public abstract C fromAst(A astNode, Class
Transforms an AST representation back into a specific Java type.
Parameters:
astNode - The root AST node to interpret.
clazz - The target type to instantiate and populate.
Returns:
A populated instance of the requested class.