Class SimpleClassResolver

java.lang.Object
ch.njol.yggdrasil.SimpleClassResolver
All Implemented Interfaces:
ClassResolver

@NotThreadSafe public class SimpleClassResolver extends Object implements ClassResolver
  • Constructor Details

    • SimpleClassResolver

      public SimpleClassResolver()
  • Method Details

    • registerClass

      public void registerClass(Class<?> c, String id)
    • getClass

      public @Nullable Class<?> getClass(String id)
      Description copied from interface: ClassResolver
      Resolves a class by its ID.
      Specified by:
      getClass in interface ClassResolver
      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

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

      // TODO make sure that it's unique

      Specified by:
      getID in interface ClassResolver
      Parameters:
      c - 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