Class CompactSerializationConfig


  • public class CompactSerializationConfig
    extends java.lang.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 Detail

      • CompactSerializationConfig

        public CompactSerializationConfig()
    • Method Detail

      • addClass

        public <T> CompactSerializationConfig addClass​(@Nonnull
                                                       java.lang.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
                                                     java.lang.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
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object