Class ConfigurationSerialization
java.lang.Object
org.bspfsystems.yamlconfiguration.serialization.ConfigurationSerialization
A utility class for storing and retrieving classes for configurations.
Synchronized with the commit on 19-November-2023.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable ConfigurationSerializabledeserializeObject(@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.static @Nullable ConfigurationSerializabledeserializeObject(@NotNull Map<String, ?> map, @NotNull Class<? extends ConfigurationSerializable> clazz) Attempts to deserialize the given map into a new instance of the given class.static @NotNull StringgetAlias(@NotNull Class<? extends ConfigurationSerializable> clazz) Gets the primary alias for the given configuration serializable class.static @Nullable Class<? extends ConfigurationSerializable>getClassByAlias(@NotNull String alias) Attempts to get a registered configuration serializable class by its alias.static voidregisterClass(@NotNull Class<? extends ConfigurationSerializable> clazz) Registers the given configuration serializable class by any and all aliases/delegate deserializations.static voidregisterClass(@NotNull Class<? extends ConfigurationSerializable> clazz, @NotNull String alias) Registers the given alias to the given configuration serializable class.static voidunregisterClass(@NotNull Class<? extends ConfigurationSerializable> clazz) Unregisters any aliases for the given configuration serializable classstatic voidunregisterClass(@NotNull String alias) Unregisters the specified alias.
-
Field Details
-
SERIALIZED_TYPE_KEY
- See Also:
-
-
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),
nullwill 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),
nullwill 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
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
nullif 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.
-