com.hazelcast.spi.serialization

## Interface SerializationService

-     public interface SerializationService

  SPI to serialize user objects to `Data` and back to Object `Data` is the internal representation of binary data in hazelcast.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `ManagedContext` | `getManagedContext()` see `Config.setManagedContext(ManagedContext)`
    `<B extends Data> B` | `toData(Object obj)` Serializes an object to a `Data`.
    `<B extends Data> B` | `toData(Object obj, PartitioningStrategy strategy)` Serializes an object to a `Data`.
    `<T> T` | `toObject(Object data)` Deserializes an object.
    `<T> T` | `toObject(Object data, Class klazz)` Deserializes an object.

- - ### Method Detail

    - #### toData

          <B extends Data> B toData(Object obj)

      Serializes an object to a `Data`.

      This method can safely be called with a `Data` instance. In that case, that instance is returned.

      If this method is called with null, null is returned.
      Parameters:
        `obj` - the object to serialize.
      Returns:
        the serialized object.
      Throws:
        `HazelcastSerializationException` - when serialization fails.

    - #### toData

          <B extends Data> B toData(Object obj,
                                    PartitioningStrategy strategy)

      Serializes an object to a `Data`.

      This method can safely be called with a `Data` instance. In that case, that instance is returned.

      If this method is called with null, null is returned.
      Parameters:
        `obj` - the object to serialize.
        `strategy` - strategy is used to calculate partition ID of the resulting data see `PartitioningStrategy`
      Returns:
        the serialized object.
      Throws:
        `HazelcastSerializationException` - when serialization fails.

    - #### toObject

          <T> T toObject(Object data)

      Deserializes an object.

      This method can safely be called on an object that is already deserialized. In that case, that instance is returned.

      If this method is called with null, null is returned.
      Parameters:
        `data` - the data to deserialize.
      Returns:
        the deserialized object.
      Throws:
        `HazelcastSerializationException` - when deserialization fails.

    - #### toObject

          <T> T toObject(Object data,
                         Class klazz)

      Deserializes an object.

      This method can safely be called on an object that is already deserialized. In that case, that instance is returned.

      If this method is called with null, null is returned.
      Parameters:
        `data` - the data to deserialize.
        `klazz` - The class to instantiate when deserializing the object.
      Returns:
        the deserialized object.
      Throws:
        `HazelcastSerializationException` - when deserialization fails.

    - #### getManagedContext

          ManagedContext getManagedContext()

      see `Config.setManagedContext(ManagedContext)`
      Returns:
        ManagedContext that is set by user in Config

Copyright © 2020. All rights reserved.