Class CompactSerializationConfig

java.lang.Object
com.hazelcast.config.CompactSerializationConfig

public class CompactSerializationConfig extends Object
In 5.0, this feature is disabled by default and has to be enabled via configuration

Once enabled the classes which does not match to any other serialization methods will be serialized in the new format automatically via help of reflection without needing any other configuration. For this case, the class should not implement `Serializable`, `Externalizable`, `Portable`, `IdentifiedDataSerializable`, `DataSerializable` or the class should not be registered as a custom serializer.

For automatic serialization with reflection, only types in CompactWriter/CompactReader interface and char, Character, enum, and their arrays are supported as fields. For any other field type, the reflective serializer will work recursively and try to de/serialize those as nested Compact objects.

To explicitly configure a class to be serialized with Compact format following methods can be used.

On the first two methods listed above, reflection is not utilized. Instead, the given serializer is used to serialize/deserialize users objects.

Since:
5.2
  • Constructor Details

    • CompactSerializationConfig

      public CompactSerializationConfig()
    • CompactSerializationConfig

      public CompactSerializationConfig(CompactSerializationConfig config)
  • Method Details

    • addClass

      public <T> CompactSerializationConfig addClass(@Nonnull Class<T> clazz)
      Registers the class to be serialized with Compact serialization.

      For the given class, Compact serialization will be used instead of Portable, Identified, Java Serializable, or GlobalSerializer.

      Type name is determined automatically from the class, which is its fully qualified class name.

      Field types are determined automatically from the class with reflection.

      Parameters:
      clazz - Class to be serialized with Compact serialization
      Returns:
      configured CompactSerializationConfig for chaining
    • setClasses

      public CompactSerializationConfig setClasses(@Nonnull Class<?>... classes)
      Registers multiple classes to be serialized with Compact serialization.

      For the given classes, Compact serialization will be used instead of Portable, Identified, Java Serializable, or GlobalSerializer.

      Type names are determined automatically from the classes, which are their fully qualified class names.

      Field types are determined automatically from the classes with reflection.

      This method will clear previous class registrations.

      Parameters:
      classes - Classes to be serialized with Compact serialization
      Returns:
      configured CompactSerializationConfig for chaining
    • addSerializer

      public <T> CompactSerializationConfig addSerializer(@Nonnull CompactSerializer<T> serializer)
      Registers the given Compact serializer.

      For the class returned by the serializer's CompactSerializer.getCompactClass() method, Compact serialization will be used instead of Portable, Identified, Java Serializable, or GlobalSerializer.

      Type name will be read from the serializer's CompactSerializer.getTypeName() method.

      Parameters:
      serializer - Serializer to be registered
      Returns:
      configured CompactSerializationConfig for chaining
    • setSerializers

      public CompactSerializationConfig setSerializers(@Nonnull CompactSerializer<?>... serializers)
      Registers the given Compact serializers.

      For the classes returned by the serializers' CompactSerializer.getCompactClass() method, Compact serialization will be used instead of Portable, Identified, Java Serializable, or GlobalSerializer.

      Type names will be read from the serializers' CompactSerializer.getTypeName() method.

      This method will clear previous serializer registrations.

      Parameters:
      serializers - Serializers to be registered
      Returns:
      configured CompactSerializationConfig for chaining
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object