public static final class KryoNamespace.Builder extends Object
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
KryoNamespace |
build()
Builds a
KryoNamespace instance. |
KryoNamespace |
build(String friendlyName)
Builds a
KryoNamespace instance. |
KryoNamespace.Builder |
nextId(int id)
Sets the next Kryo registration Id for following register entries.
|
KryoNamespace.Builder |
register(Class<?>... expectedTypes)
Registers classes to be serialized using Kryo default serializer.
|
KryoNamespace.Builder |
register(KryoNamespace ns)
Registers all the class registered to given KryoNamespace.
|
KryoNamespace.Builder |
register(com.esotericsoftware.kryo.Serializer<?> serializer,
Class<?>... classes)
Registers serializer for the given set of classes.
|
KryoNamespace.Builder |
setCompatible(boolean compatible)
Sets whether backwards/forwards compatible versioned serialization is enabled.
|
KryoNamespace.Builder |
setRegistrationRequired(boolean registrationRequired)
Sets the registrationRequired flag.
|
public KryoNamespace build()
KryoNamespace
instance.public KryoNamespace build(String friendlyName)
KryoNamespace
instance.friendlyName
- friendly name for the namespacepublic KryoNamespace.Builder nextId(int id)
id
- Kryo registration IdKryo.register(Class, Serializer, int)
public KryoNamespace.Builder register(Class<?>... expectedTypes)
expectedTypes
- list of classespublic KryoNamespace.Builder register(com.esotericsoftware.kryo.Serializer<?> serializer, Class<?>... classes)
When multiple classes are registered with an explicitly provided serializer, the namespace guarantees all instances will be serialized with the same type ID.
classes
- list of classes to registerserializer
- serializer to use for the classpublic KryoNamespace.Builder register(KryoNamespace ns)
ns
- KryoNamespacepublic KryoNamespace.Builder setCompatible(boolean compatible)
When compatible serialization is enabled, the CompatibleFieldSerializer
will be set as the
default serializer for types that do not otherwise explicitly specify a serializer.
compatible
- whether versioned serialization is enabledpublic KryoNamespace.Builder setRegistrationRequired(boolean registrationRequired)
registrationRequired
- Kryo's registrationRequired flagKryo.setRegistrationRequired(boolean)