Package net.storm.api.plugins.config
Interface Serializer<T>
- Type Parameters:
T- the type this serializer handles
public interface Serializer<T>
Interface for custom configuration value serialization.
Serializers convert configuration values between their object representation and string format for storage. Custom serializers are used for complex types that cannot be automatically serialized by the configuration system.
To use a custom serializer, annotate the configuration type with ConfigSerializer:
@ConfigSerializer(MyTypeSerializer.class)
public class MyType {
// Type definition
}
public class MyTypeSerializer implements Serializer<MyType> {
@Override
public String serialize(MyType value) {
return value.toString(); // Custom serialization logic
}
@Override
public MyType deserialize(String s) {
return MyType.parse(s); // Custom deserialization logic
}
}
- See Also:
-
Method Summary
-
Method Details
-
serialize
Converts a value to its string representation for storage.- Parameters:
value- the value to serialize- Returns:
- the string representation
-
deserialize
Converts a string back to the original value type.- Parameters:
s- the string to deserialize- Returns:
- the deserialized value
-