Class DefaultEntitySerializer
java.lang.Object
com.mewna.catnip.entity.serialization.DefaultEntitySerializer
- All Implemented Interfaces:
EntitySerializer<Void>
- Since:
- 9/12/19.
- Author:
- amy
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
DefaultEntitySerializer
public DefaultEntitySerializer()
-
-
Method Details
-
serialize
Description copied from interface:EntitySerializer
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.
- Specified by:
serialize
in interfaceEntitySerializer<Void>
- Parameters:
entity
- The entity to serialize.- Returns:
- The serialized entity data.
-
deserialize
@Nonnull @CheckReturnValue public <E extends Entity> E deserialize(@Nonnull Void data, @Nonnull Class<E> as) Description copied from interface:EntitySerializer
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 inEntitySerializer.serialize(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.
- Specified by:
deserialize
in interfaceEntitySerializer<Void>
- 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.
-