auto.parcel.processor.gwtserializer.vm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of auto-parcel-processor Show documentation
Show all versions of auto-parcel-processor Show documentation
Port of Google AutoValue for the Android platform
The newest version!
## Template for each generated AutoValue_Foo_CustomFieldSerializer class.
## This template uses the Apache Velocity Template Language (VTL).
## The variables ($pkg, $props, and so on) are defined by the fields of
## GwtSerialization.GwtTemplateVars.
##
## Comments, like this one, begin with ##. The comment text extends up to and including the newline
## character at the end of the line. So comments also serve to join a line to the next one.
## Velocity deletes a newline after a directive (#if, #foreach, #end etc) so ## is not needed there.
## That does mean that we sometimes need an extra blank line after such a directive.
##
## A post-processing step will remove unwanted spaces and blank lines, but will not join two lines.
## TODO(emcmanus): perform the post-processing.
#if (!$pkg.empty)
package $pkg;
#end
#foreach ($i in $imports)
import $i;
#end
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.SerializationStreamReader;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
@${generated}("com.google.auto.value.processor.AutoValueProcessor")
public final class $serializerClass {
// There are no instances of this class.
private ${serializerClass}() {}
public static $subclass instantiate(
SerializationStreamReader streamReader) throws SerializationException {
#foreach ($p in $props)
#if ($p.castingUnchecked)
@SuppressWarnings("unchecked")
#end
$p.type $p = ${p.gwtCast}streamReader.read${p.gwtType}();
#end
return new ${subclass}(#foreach ($p in $props) $p #if ($foreach.hasNext) , #end #end);
}
public static void serialize(
SerializationStreamWriter streamWriter,
$subclass instance) throws SerializationException {
#foreach ($p in $props)
streamWriter.write${p.gwtType}(instance.${p.getter}());
#end
}
public static void deserialize(
@SuppressWarnings("unused") SerializationStreamReader streamReader,
@SuppressWarnings("unused") $subclass instance) {
// instantiate already did all the work.
}
// This dummy field is a hash of the fields in $subclass that will change if they do, including
// if their order changes. This is because GWT identity for a class that has a serializer is
// based on the fields of the serializer rather than the class itself.
@SuppressWarnings("unused")
private int dummy_$classHashString;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy