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 Details

    • logger

      protected final org.slf4j.Logger logger
    • typeClass

      protected final Class<?> typeClass
  • Constructor Details

    • DefaultSerializationAdapter

      public DefaultSerializationAdapter(Class<?> typeClass)
      Creates a new instance of the adapter.
      Parameters:
      typeClass - The class of the type to serialize.
  • Method Details

    • serialize

      @NotNull public Map<Object,Object> serialize(@NotNull T object)
      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 (== for StandardSerializer.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 interface dev.dejvokep.boostedyaml.serialization.standard.TypeAdapter<T>
      Parameters:
      object - object to serialize
      Returns:
      the serialized object
    • deserialize

      @NotNull public T deserialize(@NotNull Map<Object,Object> map)
      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 interface dev.dejvokep.boostedyaml.serialization.standard.TypeAdapter<T>
      Parameters:
      map - the raw map to deserialize
      Returns:
      the deserialized object