java.lang.Object
org.bspfsystems.yamlconfiguration.serialization.ConfigurationSerialization

public final class ConfigurationSerialization extends Object
A utility class for storing and retrieving classes for configurations.

Synchronized with the commit on 19-November-2023.

  • Field Details

  • Method Details

    • deserializeObject

      @Nullable public static @Nullable ConfigurationSerializable deserializeObject(@NotNull @NotNull Map<String,?> map, @NotNull @NotNull Class<? extends ConfigurationSerializable> clazz)
      Attempts to deserialize the given map into a new instance of the given class.

      The class must implement configuration serializable, including the extra methods and/or constructor as specified in the javadocs of a configuration serializable.

      If a new instance could not be made (an example being the class not fully implementing the interface), null will be returned.

      Parameters:
      map - The map to deserialize.
      clazz - The class to deserialize into.
      Returns:
      The new instance of the specified class.
    • deserializeObject

      @Nullable public static @Nullable ConfigurationSerializable deserializeObject(@NotNull @NotNull Map<String,?> map)
      Attempts to deserialize the given map into a new instance of any known type of configuration serializable that may be indicated by the data contained within the map itself.

      The class must implement configuration serializable, including the extra methods and/or constructor as specified in the javadocs of a configuration serializable.

      If a new instance could not be made (an example being the class not fully implementing the interface), null will be returned.

      Parameters:
      map - The map to deserialize.
      Returns:
      The new instance of the given data.
    • registerClass

      public static void registerClass(@NotNull @NotNull Class<? extends ConfigurationSerializable> clazz)
      Registers the given configuration serializable class by any and all aliases/delegate deserializations.
      Parameters:
      clazz - The class to register.
    • registerClass

      public static void registerClass(@NotNull @NotNull Class<? extends ConfigurationSerializable> clazz, @NotNull @NotNull String alias)
      Registers the given alias to the given configuration serializable class.
      Parameters:
      clazz - The class to register.
      alias - Alias to register the class as.
      See Also:
    • unregisterClass

      public static void unregisterClass(@NotNull @NotNull String alias)
      Unregisters the specified alias.
      Parameters:
      alias - The alias to unregister.
    • unregisterClass

      public static void unregisterClass(@NotNull @NotNull Class<? extends ConfigurationSerializable> clazz)
      Unregisters any aliases for the given configuration serializable class
      Parameters:
      clazz - The class to unregister.
    • getClassByAlias

      @Nullable public static @Nullable Class<? extends ConfigurationSerializable> getClassByAlias(@NotNull @NotNull String alias)
      Attempts to get a registered configuration serializable class by its alias.
      Parameters:
      alias - The alias of the configuration serializable to retrieve.
      Returns:
      The requested configuration serializable, or null if one is not found.
    • getAlias

      @NotNull public static @NotNull String getAlias(@NotNull @NotNull Class<? extends ConfigurationSerializable> clazz)
      Gets the primary alias for the given configuration serializable class.
      Parameters:
      clazz - The class to retrieve the primary alias of.
      Returns:
      The primary alias of the given configuration serializable.