Class SimpleClassSerializer<T>

java.lang.Object
ch.njol.yggdrasil.YggdrasilSerializer<T>
ch.njol.yggdrasil.SimpleClassSerializer<T>
Type Parameters:
T - the type of the class to serialize
All Implemented Interfaces:
ClassResolver
Direct Known Subclasses:
SimpleClassSerializer.NonInstantiableClassSerializer

public abstract class SimpleClassSerializer<T> extends YggdrasilSerializer<T>
A simple serializer for a single class. Useful for registering serializers for external classes that should not have their own classinfos, and that are not handled by ConfigurationSerializer
  • Field Details

    • type

      protected final Class<T> type
    • id

      protected final String id
  • Constructor Details

    • SimpleClassSerializer

      public SimpleClassSerializer(Class<T> type, String id)
  • Method Details

    • getClass

      @Nullable public @Nullable Class<? extends T> getClass(String id)
      Description copied from interface: ClassResolver
      Resolves a class by its ID.
      Specified by:
      getClass in interface ClassResolver
      Specified by:
      getClass in class YggdrasilSerializer<T>
      Parameters:
      id - The ID used when storing objects
      Returns:
      The Class object that represents data with the given ID, or null if the ID does not belong to the implementor
    • getID

      @Nullable public @Nullable String getID(Class<?> clazz)
      Description copied from interface: ClassResolver
      Gets an ID for a Class. The ID is used to identify the type of saved object.

      Parameters:
      clazz - The class to get the ID of
      Returns:
      The ID of the given class, or null if this is not a class of the implementor