Class KryoNamespace.Builder

  • Enclosing class:
    KryoNamespace

    public static final class KryoNamespace.Builder
    extends java.lang.Object
    KryoNamespace builder.
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • build

        public KryoNamespace build​(java.lang.String friendlyName)
        Builds a KryoNamespace 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 register
        serializer - 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)