Package org.onlab.util
Class KryoNamespace.Builder
- java.lang.Object
-
- org.onlab.util.KryoNamespace.Builder
-
- Enclosing class:
- KryoNamespace
public static final class KryoNamespace.Builder extends java.lang.Object
KryoNamespace builder.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KryoNamespace
build()
Builds aKryoNamespace
instance.KryoNamespace
build(java.lang.String friendlyName)
Builds aKryoNamespace
instance.KryoNamespace.Builder
nextId(int id)
Sets the next Kryo registration Id for following register entries.KryoNamespace.Builder
register(com.esotericsoftware.kryo.Serializer<?> serializer, java.lang.Class<?>... classes)
Registers serializer for the given set of classes.KryoNamespace.Builder
register(java.lang.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
setCompatible(boolean compatible)
Sets whether backwards/forwards compatible versioned serialization is enabled.KryoNamespace.Builder
setRegistrationRequired(boolean registrationRequired)
Sets the registrationRequired flag.
-
-
-
Method Detail
-
build
public KryoNamespace build()
Builds aKryoNamespace
instance.- Returns:
- KryoNamespace
-
build
public KryoNamespace build(java.lang.String friendlyName)
Builds aKryoNamespace
instance.- Parameters:
friendlyName
- friendly name for the namespace- Returns:
- KryoNamespace
-
nextId
public KryoNamespace.Builder nextId(int id)
Sets the next Kryo registration Id for following register entries.- Parameters:
id
- Kryo registration Id- Returns:
- this
- See Also:
Kryo.register(Class, Serializer, int)
-
register
public KryoNamespace.Builder register(java.lang.Class<?>... expectedTypes)
Registers classes to be serialized using Kryo default serializer.- Parameters:
expectedTypes
- list of classes- Returns:
- this
-
register
public KryoNamespace.Builder register(com.esotericsoftware.kryo.Serializer<?> serializer, java.lang.Class<?>... classes)
Registers serializer for the given set of classes.When multiple classes are registered with an explicitly provided serializer, the namespace guarantees all instances will be serialized with the same type ID.
- Parameters:
classes
- list of classes to registerserializer
- serializer to use for the class- Returns:
- this
-
register
public KryoNamespace.Builder register(KryoNamespace ns)
Registers all the class registered to given KryoNamespace.- Parameters:
ns
- KryoNamespace- Returns:
- this
-
setCompatible
public KryoNamespace.Builder setCompatible(boolean compatible)
Sets whether backwards/forwards compatible versioned serialization is enabled.When compatible serialization is enabled, the
CompatibleFieldSerializer
will be set as the default serializer for types that do not otherwise explicitly specify a serializer.- Parameters:
compatible
- whether versioned serialization is enabled- Returns:
- this
-
setRegistrationRequired
public KryoNamespace.Builder setRegistrationRequired(boolean registrationRequired)
Sets the registrationRequired flag.- Parameters:
registrationRequired
- Kryo's registrationRequired flag- Returns:
- this
- See Also:
Kryo.setRegistrationRequired(boolean)
-
-