Interface EntitySerializer<T>
- Type Parameters:
T
- The type of the serialized data.
- All Known Implementing Classes:
DefaultEntitySerializer
public interface EntitySerializer<T>
A generic behaviour for de/serializing catnip entities. The default
implementation is
DefaultEntitySerializer
, which does
nothing but throw on method calls. You must provide a serializer
that properly handles de/serialization requests.- Since:
- 9/12/19.
- Author:
- amy
-
Method Summary
-
Method Details
-
serialize
Serializes the given entity. This method should handle things like converting snowflakes into strings, if the serialization method in use (ex. JSON) doesn't support bigints.
It is strongly recommended that you add in functionality to determine the catnip version that an entity was serialized with, so as to avoid potential version mismatch errors.
- Parameters:
entity
- The entity to serialize.- Returns:
- The serialized entity data.
-
deserialize
Deserializes the given data into an entity of the right type. This method should handle things like converting strings into snowflakes, if the serialization method in use (ex. JSON) doesn't support bigints; that is, it should effectively undo any data transformations done inserialize(Entity)
.
It is strongly recommended that you add in functionality to determine the catnip version that an entity was serialized with, so as to avoid potential version mismatch errors.
- Type Parameters:
E
- The type of the target entity.- Parameters:
data
- The data to deserialize.as
- The type of entity to deserialize data into.- Returns:
- The entity deserialized from the given data.
-