Class SerializationUtils
java.lang.Object
io.github.blyznytsiaorg.bibernate.cache.utils.SerializationUtils
Utility class for serializing and deserializing objects using Kryo serialization.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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.static <T> byte[]
Serializes the provided entity object into a byte array using Kryo serialization.
-
Constructor Details
-
SerializationUtils
public SerializationUtils()
-
-
Method Details
-
serialize
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 objectentity
- the entity object to serialize- Returns:
- the byte array representing the serialized entity
-
deserialize
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 objectentity
- the byte array representing the serialized entity- Returns:
- an Optional containing the deserialized entity object, or an empty Optional if deserialization fails
-