CustomSerializationScheme
Keywords: net.corda.core.serialization.CustomSerializationScheme interface
Date: 2023-09-18

net.corda.core.serialization

## Interface CustomSerializationScheme

-     public CustomSerializationScheme

  Implement this interface to add your own Serialization Scheme. This is an experimental feature. All methods in this class MUST be thread safe i.e. methods from the same instance of this class can be called in different threads simultaneously.

- - ### Constructor Detail

    - #### CustomSerializationScheme

          public CustomSerializationScheme()

  - ### Method Detail

    - #### getSchemeId

          int getSchemeId()

      This method must return an id used to uniquely identify the Scheme. This should be unique within a network as serialized data might be sent over the wire.

    - #### deserialize

          @NotNull
          <T> T deserialize(@NotNull
                                     ByteSequence bytes,
                                     @NotNull
                                     java.lang.Class<T> clazz,
                                     @NotNull
                                     SerializationSchemeContext context)

      This method must deserialize the data stored `bytes` into an instance of T.

      Parameters:
        `bytes` - the serialized data.
        `clazz` - the class to instantiate.
        `context` - used to pass information about how the object should be deserialized.
      See Also:
        `bytes`

    - #### serialize

          @NotNull
          <T> ByteSequence serialize(@NotNull
                                              T obj,
                                              @NotNull
                                              SerializationSchemeContext context)

      This method must be able to serialize any object T into a ByteSequence.

      Parameters:
        `obj` - the object to be serialized.
        `context` - used to pass information about how the object should be serialized.