Interface DataClassCodec
public interface DataClassCodec
The blueprint of the internally generated class to serialize and deserialize the fields of an object into a buffer.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize(@NonNull eu.cloudnetservice.driver.network.buffer.DataBuf source, @NonNull eu.cloudnetservice.driver.network.object.ObjectMapper mapper) Deserializes the target object of this codec from the given buffer using the given object mapper to deserialize the field values.voidserialize(eu.cloudnetservice.driver.network.buffer.DataBuf.Mutable target, @NonNull eu.cloudnetservice.driver.network.object.ObjectMapper mapper, @NonNull Object instance) Serializes the target object of this codec from the given instance into the given buffer using the given object mapper to serialize the field values.
-
Method Details
-
deserialize
@NonNull @NonNull Object deserialize(@NonNull @NonNull eu.cloudnetservice.driver.network.buffer.DataBuf source, @NonNull @NonNull eu.cloudnetservice.driver.network.object.ObjectMapper mapper) Deserializes the target object of this codec from the given buffer using the given object mapper to deserialize the field values. This method will call the all-args constructor of the target class with the deserialized arguments and is not implemented for subclasses.- Parameters:
source- the source from which the class field data should be read.mapper- the mapper to use to deserialize field values.- Returns:
- the constructed object using the deserialized values and colling the all-args constructor.
- Throws:
NullPointerException- if the given source or mapper is null.
-
serialize
void serialize(@NonNull eu.cloudnetservice.driver.network.buffer.DataBuf.Mutable target, @NonNull @NonNull eu.cloudnetservice.driver.network.object.ObjectMapper mapper, @NonNull @NonNull Object instance) Serializes the target object of this codec from the given instance into the given buffer using the given object mapper to serialize the field values. Each class in the hierarchy of the root target has it's only serializer to allow private field serialization.- Parameters:
target- the target buffer into which the field values should be serialized.mapper- the object mapper to use to serialize the field values.instance- the object instance that should be serialized.- Throws:
NullPointerException- if the given target buffer, object mapper or instance is null.
-