Class VersionFieldSerializer<T>


  • public class VersionFieldSerializer<T>
    extends FieldSerializer<T>
    Serializes objects using direct field assignment, providing backward compatibility with minimal overhead. This means fields can be added without invalidating previously serialized bytes. Removing, renaming, or changing the type of a field is not supported.

    When a field is added, it must have the VersionFieldSerializer.Since annotation to indicate the version it was added in order to be compatible with previously serialized bytes. The annotation value must never change.

    Compared to FieldSerializer, VersionFieldSerializer writes a single additional varint and requires annotations for added fields, but provides backward compatibility so fields can be added. TaggedFieldSerializer provides more flexibility for classes to evolve in exchange for a slightly larger serialized size.

    Author:
    Nathan Sweet