Package dev.demeng.pluginbase.serialize
Interface YamlSerializable
- All Known Implementing Classes:
BlockPosition,Point,Position,Vector3d
public interface YamlSerializable
An object that can be serialized to a YAML configuration section. Implementing classes should
implement a public static
deserialize(ConfigurationSection) method.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends YamlSerializable>
Tdeserialize(@NotNull Class<T> clazz, @NotNull org.bukkit.configuration.ConfigurationSection section) Deserializes a ConfigurationSection to a YamlSerializable object.static @NotNull YamlSerializabledeserializeRaw(@NotNull Class<?> clazz, @NotNull org.bukkit.configuration.ConfigurationSection section) Deserializes a ConfigurationSection to a YamlSerializable object.static @Nullable MethodgetDeserializeMethod(@NotNull Class<?> clazz) Gets the deserialization method for a given class.voidserialize(@NotNull org.bukkit.configuration.ConfigurationSection section) Serializes the object into the configuration section.
-
Method Details
-
deserialize
@NotNull static <T extends YamlSerializable> T deserialize(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section) Deserializes a ConfigurationSection to a YamlSerializable object.- Type Parameters:
T- The YamlSerializable type- Parameters:
clazz- The YamlSerializable classsection- The configuration section to deserialize- Returns:
- The deserialized object
- Throws:
IllegalStateException- If the class does not have a deserialization method
-
deserializeRaw
@NotNull static @NotNull YamlSerializable deserializeRaw(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section) Deserializes a ConfigurationSection to a YamlSerializable object.- Parameters:
clazz- The YamlSerializable classsection- The configuration section to deserialize- Returns:
- The deserialized object
- Throws:
IllegalStateException- If the clazz does not have a deserialization method
-
getDeserializeMethod
Gets the deserialization method for a given class.- Parameters:
clazz- the class- Returns:
- The deserialization method, if the class has one
-
serialize
void serialize(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section) Serializes the object into the configuration section. The configuration file is not saved after serialization.- Parameters:
section- The section the object will be serialized into
-