Class TaggedFieldSerializer<T>
- java.lang.Object
-
- com.esotericsoftware.kryo.Serializer<T>
-
- com.esotericsoftware.kryo.serializers.FieldSerializer<T>
-
- com.esotericsoftware.kryo.serializers.TaggedFieldSerializer<T>
-
- All Implemented Interfaces:
java.util.Comparator<FieldSerializer.CachedField>
public class TaggedFieldSerializer<T> extends FieldSerializer<T>
Serializes objects using direct field assignment for fields that have beentagged
. Fields without theTaggedFieldSerializer.Tag
annotation are not serialized. New tagged fields can be added without invalidating previously serialized bytes. If any tagged field is removed, previously serialized bytes are invalidated. Instead of removing fields, apply theDeprecated
annotation and they will not be serialized. If fields are public, bytecode generation will be used instead of reflection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TaggedFieldSerializer.Tag
If true, this field will not be serialized.-
Nested classes/interfaces inherited from class com.esotericsoftware.kryo.serializers.FieldSerializer
FieldSerializer.CachedField<X>, FieldSerializer.Optional
-
-
Constructor Summary
Constructors Constructor Description TaggedFieldSerializer(Kryo kryo, java.lang.Class type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
initializeCachedFields()
T
read(Kryo kryo, Input input, java.lang.Class<T> type)
Reads bytes and returns a new object of the specified concrete type.void
removeField(java.lang.String fieldName)
Removes a field so that it won't be serialized.void
write(Kryo kryo, Output output, T object)
Writes the bytes for the object to the output.-
Methods inherited from class com.esotericsoftware.kryo.serializers.FieldSerializer
compare, copy, create, createCopy, getField, getFields, getType, setFieldsAsAccessible, setFieldsCanBeNull, setFixedFieldTypes, setIgnoreSyntheticFields
-
Methods inherited from class com.esotericsoftware.kryo.Serializer
getAcceptsNull, isImmutable, setAcceptsNull, setGenerics, setImmutable
-
-
-
-
Constructor Detail
-
TaggedFieldSerializer
public TaggedFieldSerializer(Kryo kryo, java.lang.Class type)
-
-
Method Detail
-
initializeCachedFields
protected void initializeCachedFields()
- Overrides:
initializeCachedFields
in classFieldSerializer<T>
-
removeField
public void removeField(java.lang.String fieldName)
Description copied from class:FieldSerializer
Removes a field so that it won't be serialized.- Overrides:
removeField
in classFieldSerializer<T>
-
write
public void write(Kryo kryo, Output output, T object)
Description copied from class:Serializer
Writes the bytes for the object to the output.This method should not be called directly, instead this serializer can be passed to
Kryo
write methods that accept a serialier.- Overrides:
write
in classFieldSerializer<T>
object
- May be null ifSerializer.getAcceptsNull()
is true.
-
read
public T read(Kryo kryo, Input input, java.lang.Class<T> type)
Description copied from class:Serializer
Reads bytes and returns a new object of the specified concrete type.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 usesKryo
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.- Overrides:
read
in classFieldSerializer<T>
- Returns:
- May be null if
Serializer.getAcceptsNull()
is true.
-
-