Interface TypeSerializer<T>
- Type Parameters:
T- the type this serializer handles
- All Known Implementing Classes:
DurationSerializer,PrimitiveSerializers.BooleanSerializer,PrimitiveSerializers.ByteSerializer,PrimitiveSerializers.CharacterSerializer,PrimitiveSerializers.DoubleSerializer,PrimitiveSerializers.FloatSerializer,PrimitiveSerializers.IntegerSerializer,PrimitiveSerializers.LongSerializer,PrimitiveSerializers.ShortSerializer,PrimitiveSerializers.StringSerializer,UUIDSerializer
public interface TypeSerializer<T>
Handles conversion between configuration nodes and Java types.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanChecks if this serializer can handle the given type.deserialize(@NotNull ConfigNode node, @NotNull Class<T> type) Deserializes a configuration node to the target type.voidserialize(T value, @NotNull MutableConfigNode node) Serializes a value to a configuration node.
-
Method Details
-
deserialize
T deserialize(@NotNull @NotNull ConfigNode node, @NotNull @NotNull Class<T> type) throws SerializationException Deserializes a configuration node to the target type.- Parameters:
node- the source nodetype- the target type class- Returns:
- the deserialized value
- Throws:
SerializationException- if deserialization fails
-
serialize
void serialize(@NotNull T value, @NotNull @NotNull MutableConfigNode node) throws SerializationException Serializes a value to a configuration node.- Parameters:
value- the value to serializenode- the target node- Throws:
SerializationException- if serialization fails
-
canHandle
Checks if this serializer can handle the given type.Used for dynamic serializer selection when the exact type is not registered but a compatible serializer exists.
- Parameters:
type- the type to check- Returns:
- true if this serializer can handle the type
-