Top Description Inners Constructors Methods
com.google.auto.value.extension.serializable.serializer.impl

public final Class OptionalSerializerExtension

extends Object
implements SerializerExtension
Class Inheritance
All Implemented Interfaces
com.google.auto.value.extension.serializable.serializer.interfaces.SerializerExtension
Annotations
@AutoService:SerializerExtension
Imports
com.google.auto.common.MoreTypes, com.google.auto.service.AutoService, com.google.auto.value.extension.serializable.serializer.interfaces.Serializer, .SerializerExtension, .SerializerFactory, com.squareup.javapoet.CodeBlock, java.util.Optional, javax.annotation.processing.ProcessingEnvironment, javax.lang.model.type.TypeKind, javax.lang.model.type.TypeMirror

A SerializerExtension that enables Optional types to be serialized.

The type argument T of Optional<T> is queried against the SerializerFactory.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static javax.lang.model.type.TypeMirror
getContainedType(javax.lang.model.type.TypeMirror type)

Gets the given type's first type argument.

public Optional<Serializer>
getSerializer(javax.lang.model.type.TypeMirror
the type being serialized
typeMirror
,
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
)

Implements com.google.auto.value.extension.serializable.serializer.interfaces.SerializerExtension.getSerializer.

Creates a Serializer that supports Optional types.

private static boolean
isOptional(javax.lang.model.type.TypeMirror type)

Checks if the given type is an Optional.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

OptionalSerializerExtensionback to summary
public OptionalSerializerExtension()

Method Detail

getContainedTypeback to summary
private static javax.lang.model.type.TypeMirror getContainedType(javax.lang.model.type.TypeMirror type)

Gets the given type's first type argument.

Returns the T in Optional<T>.

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

Implements com.google.auto.value.extension.serializable.serializer.interfaces.SerializerExtension.getSerializer.

Creates a Serializer that supports Optional types.

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

Doc from com.google.auto.value.extension.serializable.serializer.interfaces.SerializerExtension.getSerializer.

the type being serialized

factory:SerializerFactory

Doc from com.google.auto.value.extension.serializable.serializer.interfaces.SerializerExtension.getSerializer.

a SerializerFactory that can be used to serialize nested types

processingEnv:javax.annotation.processing.ProcessingEnvironment

Doc from com.google.auto.value.extension.serializable.serializer.interfaces.SerializerExtension.getSerializer.

the processing environment provided by the annotation processing framework

Annotations
@Override
isOptionalback to summary
private static boolean isOptional(javax.lang.model.type.TypeMirror type)

Checks if the given type is an Optional.

com.google.auto.value.extension.serializable.serializer.impl back to summary

private Class OptionalSerializerExtension.OptionalSerializer

extends Object
implements Serializer
Class Inheritance
  • java.lang.Object
  • com.google.auto.value.extension.serializable.serializer.impl.OptionalSerializerExtension.OptionalSerializer
All Implemented Interfaces
com.google.auto.value.extension.serializable.serializer.interfaces.Serializer

Field Summary

Modifier and TypeField and Description
private final Serializer

Constructor Summary

AccessConstructor and Description
pack-priv
OptionalSerializer(Serializer containedTypeSerializer)

Method Summary

Modifier and TypeMethod and Description
public CodeBlock
fromProxy(CodeBlock expression)

Implements com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.fromProxy.

Creates an expression that converts the proxy type back to the original type.

public javax.lang.model.type.TypeMirror
proxyFieldType()

Implements com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.proxyFieldType.

The proxy type the original unserializable type will be mapped to.

public CodeBlock
toProxy(CodeBlock expression)

Implements com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.toProxy.

Creates an expression that converts the original type to the proxy type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

containedTypeSerializerback to summary
private final Serializer containedTypeSerializer

Constructor Detail

OptionalSerializerback to summary
pack-priv OptionalSerializer(Serializer containedTypeSerializer)

Method Detail

fromProxyback to summary
public CodeBlock fromProxy(CodeBlock expression)

Implements com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.fromProxy.

Doc from com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.fromProxy.

Creates an expression that converts the proxy type back to the original type.

Annotations
@Override
proxyFieldTypeback to summary
public javax.lang.model.type.TypeMirror proxyFieldType()

Implements com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.proxyFieldType.

Doc from com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.proxyFieldType.

The proxy type the original unserializable type will be mapped to.

Annotations
@Override
toProxyback to summary
public CodeBlock toProxy(CodeBlock expression)

Implements com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.toProxy.

Doc from com.google.auto.value.extension.serializable.serializer.interfaces.Serializer.toProxy.

Creates an expression that converts the original type to the proxy type.

Annotations
@Override