Class SerializationUtils

java.lang.Object
io.github.blyznytsiaorg.bibernate.cache.utils.SerializationUtils

public class SerializationUtils extends Object
Utility class for serializing and deserializing objects using Kryo serialization.
Since:
1.0
Author:
Blyzhnytsia Team
  • Constructor Details

    • SerializationUtils

      public SerializationUtils()
  • Method Details

    • serialize

      public static <T> byte[] serialize(Class<T> entityClass, T entity)
      Serializes the provided entity object into a byte array using Kryo serialization.
      Type Parameters:
      T - the type of the entity object
      Parameters:
      entityClass - the class of the entity object
      entity - the entity object to serialize
      Returns:
      the byte array representing the serialized entity
    • deserialize

      public static <T> Optional<T> deserialize(Class<T> entityClass, byte[] entity)
      Deserializes the provided byte array into an object of the specified entity class using Kryo deserialization.
      Type Parameters:
      T - the type of the entity object
      Parameters:
      entityClass - the class of the entity object
      entity - the byte array representing the serialized entity
      Returns:
      an Optional containing the deserialized entity object, or an empty Optional if deserialization fails