Top Description Inners Fields Constructors Methods
com.google.auto.value.processor

pack-priv Class GwtSerialization

extends Object
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.UTF_8, java.util.stream.Collectors.toList

Generates GWT serialization code for @AutoValue classes also marked @GwtCompatible(serializable = true).
Author
Éamonn McManus

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
public static class

Field Summary

Modifier and TypeField and Description
private final GwtCompatibility
private final javax.annotation.processing.ProcessingEnvironment
private final javax.lang.model.element.TypeElement

Constructor Summary

AccessConstructor and Description
pack-priv
GwtSerialization(GwtCompatibility gwtCompatibility, javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.element.TypeElement type)

Method Summary

Modifier and TypeMethod and Description
private String
pack-priv void
maybeWriteGwtSerializer(AutoValueTemplateVars
the template variables defined for this type.
autoVars
,
String
the simple name of the AutoValue class being generated, AutoValue_Foo in the example.
finalSubclass
)

Writes the GWT serializer for the given type, if appropriate.

private boolean
private void
writeSourceFile(String className, String text, javax.lang.model.element.TypeElement originatingType)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

gwtCompatibilityback to summary
private final GwtCompatibility gwtCompatibility
processingEnvback to summary
private final javax.annotation.processing.ProcessingEnvironment processingEnv
typeback to summary
private final javax.lang.model.element.TypeElement type

Constructor Detail

GwtSerializationback to summary
pack-priv GwtSerialization(GwtCompatibility gwtCompatibility, javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.element.TypeElement type)

Method Detail

computeClassHashback to summary
private String computeClassHash(Iterable<AutoValueishProcessor.Property> props, String pkg)
maybeWriteGwtSerializerback to summary
pack-priv void maybeWriteGwtSerializer(AutoValueTemplateVars autoVars, String finalSubclass)

Writes the GWT serializer for the given type, if appropriate. An @AutoValue class gets a GWT serializer if it is annotated with @GwtCompatible(serializable = true), where the @GwtCompatible annotation can come from any package.

If the type is com.example.Foo then the generated AutoValue subclass is com.example.AutoValue_Foo and the GWT serializer is com.example.AutoValue_Foo_CustomFieldSerializer.

Parameters
autoVars:AutoValueTemplateVars

the template variables defined for this type.

finalSubclass:String

the simple name of the AutoValue class being generated, AutoValue_Foo in the example.

shouldWriteGwtSerializerback to summary
private boolean shouldWriteGwtSerializer()
writeSourceFileback to summary
private void writeSourceFile(String className, String text, javax.lang.model.element.TypeElement originatingType)
com.google.auto.value.processor back to summary

pack-priv Class GwtSerialization.GwtTemplateVars

extends TemplateVars
Class Inheritance
Annotations
@SuppressWarnings:unused

Field Summary

Modifier and TypeField and Description
pack-priv String
actualTypes

The generic signature used by the generated subclass for its superclass reference.

pack-priv ImmutableMap<String, PropertyBuilderClassifier.PropertyBuilder>
builderPropertyBuilders

A map from property names to information about the associated property builder.

pack-priv Multimap<String, BuilderSpec.PropertySetter>
builderSetters

A multimap from property names (like foo) to the corresponding setter methods (foo or setFoo).

pack-priv String
classHashString

A string that should change if any salient details of the serialized class change.

pack-priv String
formalTypes

The formal generic signature of the class with the @AutoValue annotation and its generated subclass.

pack-priv String
generated

The encoding of the Generated class.

pack-priv String
pkg

The package of the class with the @AutoValue annotation and its generated subclass.

pack-priv List<GwtSerialization.Property>
props

The properties defined by the parent class's abstract methods.

pack-priv String
serializerClass

The simple name of the generated GWT serializer class.

pack-priv String
subclass

The simple name of the generated subclass.

private static final Template
pack-priv Boolean
useBuilder

True if the @AutoValue class is constructed using a generated builder.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv Template
Inherited from com.google.auto.value.processor.TemplateVars:
parsedTemplateForResourcetoStringtoText

Field Detail

actualTypesback to summary
pack-priv String actualTypes

The generic signature used by the generated subclass for its superclass reference. This is empty, or contains only type variables with no bounds, for example <K, V>.

builderPropertyBuildersback to summary
pack-priv ImmutableMap<String, PropertyBuilderClassifier.PropertyBuilder> builderPropertyBuilders

A map from property names to information about the associated property builder. A property called foo (defined by a method foo() or getFoo()) can have a property builder called fooBuilder(). The type of foo must be a type that has an associated builder following certain conventions. Guava immutable types such as ImmutableList follow those conventions, as do many @AutoValue types.

builderSettersback to summary
pack-priv Multimap<String, BuilderSpec.PropertySetter> builderSetters

A multimap from property names (like foo) to the corresponding setter methods (foo or setFoo).

classHashStringback to summary
pack-priv String classHashString

A string that should change if any salient details of the serialized class change.

formalTypesback to summary
pack-priv String formalTypes

The formal generic signature of the class with the @AutoValue annotation and its generated subclass. This is empty, or contains type variables with optional bounds, for example <K, V extends K>.

generatedback to summary
pack-priv String generated

The encoding of the Generated class. Empty if no Generated class is available.

pkgback to summary
pack-priv String pkg

The package of the class with the @AutoValue annotation and its generated subclass.

propsback to summary
pack-priv List<GwtSerialization.Property> props

The properties defined by the parent class's abstract methods.

serializerClassback to summary
pack-priv String serializerClass

The simple name of the generated GWT serializer class.

subclassback to summary
pack-priv String subclass

The simple name of the generated subclass.

TEMPLATEback to summary
private static final Template TEMPLATE
useBuilderback to summary
pack-priv Boolean useBuilder

True if the @AutoValue class is constructed using a generated builder.

Constructor Detail

GwtTemplateVarsback to summary
pack-priv GwtTemplateVars()

Method Detail

parsedTemplateback to summary
pack-priv Template parsedTemplate()

Implements abstract com.google.auto.value.processor.TemplateVars.parsedTemplate.

Annotations
@Override
com.google.auto.value.processor back to summary

public Class GwtSerialization.Property

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final boolean
private final AutoValueishProcessor.GetterProperty

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
public String
getGwtCast()

Returns a string to be inserted before the call to the readFoo() call so that the expression can be assigned to the given type.

public String
getGwtType()

Returns the suffix in serializer method names for values of the given type.

public String
public String
public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

isCastingUncheckedback to summary
private final boolean isCastingUnchecked
propertyback to summary
private final AutoValueishProcessor.GetterProperty property

Constructor Detail

Propertyback to summary
pack-priv Property(AutoValueishProcessor.GetterProperty property)

Method Detail

getGetterback to summary
public String getGetter()
getGwtCastback to summary
public String getGwtCast()

Returns a string to be inserted before the call to the readFoo() call so that the expression can be assigned to the given type. For primitive types and String, the readInt() etc methods already return the right type so the string is empty. For other types, the string is a cast like "(Foo) ".

getGwtTypeback to summary
public String getGwtType()

Returns the suffix in serializer method names for values of the given type. For example, if the type is "int" then the returned value will be "Int" because the serializer methods are called readInt and writeInt. There are methods for all primitive types and String; every other type uses readObject and writeObject.

getNameback to summary
public String getName()
getTypeback to summary
public String getType()
isCastingUncheckedback to summary
public boolean isCastingUnchecked()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override