Package space.arim.dazzleconf.serialiser
Interface ValueSerialiser<T>
- Type Parameters:
T- the target type of deserialization
- All Known Implementing Classes:
URLValueSerialiser
public interface ValueSerialiser<T>
User-implemented interface for serializing and deserializing configuration entries.
It should always be the case that if deserialization succeeds, serializing the same value should succeed. That is,
It should always be the case that if deserialization succeeds, serializing the same value should succeed. That is,
deserialise and serialise should be inverse operations.- Author:
- A248
-
Method Summary
Modifier and TypeMethodDescriptiondeserialise(FlexibleType flexibleType) Deserializes a value from a flexible type representing a raw config value.Gets the target type of deserializationserialise(T value, Decomposer decomposer) Serializes a value to a raw config value.
-
Method Details
-
getTargetClass
Gets the target type of deserialization- Returns:
- the target class type
-
deserialise
Deserializes a value from a flexible type representing a raw config value.
The key (FlexibleType.getAssociatedKey()) is informative. It should not affect the deserialization, but should be included in thrownBadValueExceptions to inform the user which key is in question. To easily include the key in aBadValueException, useFlexibleType.badValueExceptionBuilder()- Parameters:
flexibleType- the flexible type- Returns:
- the deserialized value, never null
- Throws:
BadValueException- if the value could not be deserialized
-
serialise
Serializes a value to a raw config value. Should be the inverse operation ofdeserialise(FlexibleType)in that if the result of this method were wrapped in aFlexibleType, it could be deserialized.
If this serializer serializes values by converting from another custom type, then the provideddecomposershould be used to reserialize such custom types.- Parameters:
value- the valuedecomposer- the decomposer used to help breakdown the value- Returns:
- the serialized value
-