Class DefaultSerializationAdapter<T>
java.lang.Object
yt.sehrschlecht.classconfig.serialization.DefaultSerializationAdapter<T>
- All Implemented Interfaces:
dev.dejvokep.boostedyaml.serialization.standard.TypeAdapter<T>
public class DefaultSerializationAdapter<T>
extends Object
implements dev.dejvokep.boostedyaml.serialization.standard.TypeAdapter<T>
The default adapter for serialization. It serializes all fields that are annotated with
Serialize
.- Since:
- 1.0
- Author:
- sehrschlechtYT | https://github.com/sehrschlechtYT
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSerializationAdapter
(Class<?> typeClass) Creates a new instance of the adapter. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.dejvokep.boostedyaml.serialization.standard.TypeAdapter
toStringKeyedMap
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
typeClass
-
-
Constructor Details
-
DefaultSerializationAdapter
Creates a new instance of the adapter.- Parameters:
typeClass
- The class of the type to serialize.
-
-
Method Details
-
serialize
Serializes the given instance into a map.The returned map does not need to (but may) contain the type identifier: one entry in the top-level map (the one returned), where the key is defined by the serializer (
==
forStandardSerializer.getDefault()
) and the value identifies the serialized type - either by the full canonical classname (e.g.me.name.project.objects.CustomObject
) or it's alias. If you decide to include a type identifier, it must be registered (this requirement is not verified).If the returned map does not contain the identifier, the
serializer
will automatically use the full classname.- Specified by:
serialize
in interfacedev.dejvokep.boostedyaml.serialization.standard.TypeAdapter<T>
- Parameters:
object
- object to serialize- Returns:
- the serialized object
-
deserialize
Deserializes the given map into instance of this type.The given map is a raw object map; there are no
blocks
, just native Java objects themselves.Use
TypeAdapter.toStringKeyedMap(Map)
to convert the map.- Specified by:
deserialize
in interfacedev.dejvokep.boostedyaml.serialization.standard.TypeAdapter<T>
- Parameters:
map
- the raw map to deserialize- Returns:
- the deserialized object
-