Top Description Methods
com.google.auto.value.extension.serializable.serializer.interfaces

public Interface SerializerExtension

Known Direct Implementers
com.google.auto.value.extension.serializable.serializer.impl.ImmutableListSerializerExtension, com.google.auto.value.extension.serializable.serializer.impl.ImmutableMapSerializerExtension, com.google.auto.value.extension.serializable.serializer.impl.OptionalSerializerExtension
Imports
java.util.Optional, javax.annotation.processing.ProcessingEnvironment, javax.lang.model.type.TypeMirror

A SerializerExtension allows unserializable types to be serialized by SerializableAutoValue.

Extensions are discovered at compile time using the java.util.ServiceLoader APIs, allowing them to run without any additional annotations. To be found by ServiceLoader, an extension class must be public with a public no-arg constructor, and its fully-qualified name must appear in a file called META-INF/services/com.google.auto.value.extension.serializable.serializer.interfaces.SerializerExtension in a jar that is on the compiler's -classpath or -processorpath.

When SerializableAutoValue maps each field in an AutoValue to a serializable proxy object, it asks each SerializerExtension whether it can generate code to make the given type serializable. A SerializerExtension replies that it can by returning a non-empty Serializer.

A SerializerExtension is also provided with a SerializerFactory, which it can use to query nested types.

Method Summary

Modifier and TypeMethod and Description
public Optional<Serializer>
getSerializer(javax.lang.model.type.TypeMirror
the type being serialized
type
,
SerializerFactory
a SerializerFactory that can be used to serialize nested types
factory
,
javax.annotation.processing.ProcessingEnvironment
the processing environment provided by the annotation processing framework
processingEnv
)

Returns a Serializer if this SerializerExtension applies to the given type.

Method Detail

getSerializerback to summary
public Optional<Serializer> getSerializer(javax.lang.model.type.TypeMirror type, SerializerFactory factory, javax.annotation.processing.ProcessingEnvironment processingEnv)

Returns a Serializer if this SerializerExtension applies to the given type. Otherwise, Optional.empty is returned.

Parameters
type:javax.lang.model.type.TypeMirror

the type being serialized

factory:SerializerFactory

a SerializerFactory that can be used to serialize nested types

processingEnv:javax.annotation.processing.ProcessingEnvironment

the processing environment provided by the annotation processing framework