public class VersionFieldSerializer<T> extends FieldSerializer<T>
@Since(int)
annotation to indicate the version they were added. For a particular field, the value in
@Since
should never change once created. This is less flexible than FieldSerializer, which can handle most classes
without needing annotations, but it provides backward compatibility. This means that new fields can be added, but removing,
renaming or changing the type of any field will invalidate previous serialized bytes. VersionFieldSerializer has very little
overhead (a single additional varint) compared to FieldSerializer. Forward compatibility is not supported.TaggedFieldSerializer
Modifier and Type | Class and Description |
---|---|
static interface |
VersionFieldSerializer.Since
Incremental modification of serialized objects must add
VersionFieldSerializer.Since for new fields. |
FieldSerializer.Bind, FieldSerializer.CachedField<X>, FieldSerializer.CachedFieldFactory, FieldSerializer.CachedFieldNameStrategy, FieldSerializer.Optional
config, removedFields
Constructor and Description |
---|
VersionFieldSerializer(Kryo kryo,
Class type) |
VersionFieldSerializer(Kryo kryo,
Class type,
boolean compatible) |
Modifier and Type | Method and Description |
---|---|
protected void |
initializeCachedFields() |
T |
read(Kryo kryo,
Input input,
Class<T> type)
Reads bytes and returns a new object of the specified concrete type.
|
void |
removeField(FieldSerializer.CachedField field)
Removes a field so that it won't be serialized.
|
void |
removeField(String fieldName)
Removes a field so that it won't be serialized.
|
void |
write(Kryo kryo,
Output output,
T object)
This method can be called for different fields having the same type.
|
compare, copy, create, createCopy, getCachedFieldName, getCopyTransient, getField, getFields, getGenerics, getKryo, getSerializeTransient, getTransientFields, getType, getUseAsmEnabled, getUseMemRegions, rebuildCachedFields, rebuildCachedFields, setCopyTransient, setFieldsAsAccessible, setFieldsCanBeNull, setFixedFieldTypes, setGenerics, setIgnoreSyntheticFields, setOptimizedGenerics, setSerializeTransient, setUseAsm
getAcceptsNull, isImmutable, setAcceptsNull, setImmutable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
protected void initializeCachedFields()
initializeCachedFields
in class FieldSerializer<T>
public void removeField(String fieldName)
FieldSerializer
removeField
in class FieldSerializer<T>
public void removeField(FieldSerializer.CachedField field)
FieldSerializer
removeField
in class FieldSerializer<T>
public void write(Kryo kryo, Output output, T object)
FieldSerializer
write
in class FieldSerializer<T>
object
- May be null if Serializer.getAcceptsNull()
is true.public T read(Kryo kryo, Input input, Class<T> type)
Serializer
Before Kryo can be used to read child objects, Kryo.reference(Object)
must be called with the parent object to
ensure it can be referenced by the child objects. Any serializer that uses Kryo
to read a child object may need to
be reentrant.
This method should not be called directly, instead this serializer can be passed to Kryo
read methods that accept a
serialier.
read
in class FieldSerializer<T>
Serializer.getAcceptsNull()
is true.Copyright © 2018. All rights reserved.