Package net.storm.api.plugins.config
Annotation Interface ConfigSerializer
Annotation that specifies a custom serializer for a configuration type.
When the configuration system encounters a type annotated with @ConfigSerializer,
it will use the specified Serializer implementation to convert values
to and from strings for storage.
Example usage:
@ConfigSerializer(WorldPointSerializer.class)
public class WorldPoint {
private final int x;
private final int y;
private final int plane;
// ...
}
public class WorldPointSerializer implements Serializer<WorldPoint> {
@Override
public String serialize(WorldPoint value) {
return value.getX() + "," + value.getY() + "," + value.getPlane();
}
@Override
public WorldPoint deserialize(String s) {
String[] parts = s.split(",");
return new WorldPoint(
Integer.parseInt(parts[0]),
Integer.parseInt(parts[1]),
Integer.parseInt(parts[2])
);
}
}
- See Also:
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass<? extends Serializer<?>> The serializer class to use for this type.
-
Element Details
-
value
Class<? extends Serializer<?>> valueThe serializer class to use for this type.- Returns:
- the Serializer implementation class
-