Skip to content

Package io.github.qishr.cascara.common.lang.processor

Class AbstractSerializer

java.lang.Object
        io.github.qishr.cascara.common.lang.processor.AbstractSerializer

All Implemented Interfaces:
    Serializer

Direct Known Subtypes:
    JsonSerializer, YamlSerializer


public abstract class AbstractSerializer

Field Summary

Modifier and Type Field Description
protected Reporter reporter

Constructor Summary

Constructor Description
AbstractSerializer(String contentType, AstNodeFactory astFactory, LanguageOptions<?> options)

Method Summary

Modifier and Type Method Description
protected abstract T self()
protected abstract K serializeKey(Object key)
public T setOptions(LanguageOptions<?> options)
public Properties getServiceProperties()
public T registerTypeDescriptor(TypeDescriptor<?> typeDescriptor)
protected N serialize(Object jvmInstance) Creates the appropriate AstNode (Scalar, Sequence, or Map) based on the Java value type.
protected M serializeObject(Object jvmInstance)
protected L serializeList(List<?> list) Serializes a List into a YamlSequence.
protected M serializeMap(Map map)
protected C deserialize(AstNode node, TypeReference typeRef) Converts an AST structure back into a Java object of the generic type referenced by typeRef.
protected C deserialize(AstNode node, Class jvmType) Converts an AST structure back into a Java object of the specified type.
protected List<Field> getAllFields(Class<?> jvmType) Retrieves all declared fields for a class and all its superclasses (excluding Object).
protected List<Method> getAllMethods(Class<?> jvmType)
protected TypeDescriptor<?> getTypeDescriptor(Class<?> jvmType)
protected SerializerException error(Throwable t, Object[] details)

Field Details

reporter

protected Reporter reporter


Method Details

self

protected abstract T self()


serializeKey

protected abstract K serializeKey(Object key)


setOptions

public T setOptions(LanguageOptions<?> options)


getServiceProperties

public Properties getServiceProperties()


registerTypeDescriptor

public T registerTypeDescriptor(TypeDescriptor<?> typeDescriptor)

Specified By:

Serializer


serialize

protected N serialize(Object jvmInstance)

Creates the appropriate AstNode (Scalar, Sequence, or Map) based on the Java value type.


serializeObject

protected M serializeObject(Object jvmInstance)


serializeList

protected L serializeList(List<?> list)

Serializes a List into a YamlSequence.


serializeMap

protected M serializeMap(Map map)


deserialize

protected C deserialize(AstNode node, TypeReference typeRef)

Converts an AST structure back into a Java object of the generic type referenced by typeRef.

Throws:

SerializerException


deserialize

protected C deserialize(AstNode node, Class jvmType)

Converts an AST structure back into a Java object of the specified type.

Throws:

SerializerException


getAllFields

protected List<Field> getAllFields(Class<?> jvmType)

Retrieves all declared fields for a class and all its superclasses (excluding Object).


getAllMethods

protected List<Method> getAllMethods(Class<?> jvmType)


getTypeDescriptor

protected TypeDescriptor<?> getTypeDescriptor(Class<?> jvmType)


error

protected SerializerException error(Throwable t, Object[] details)