Package space.arim.dazzleconf.serialiser
Interface ValueSerialiser<T>
- Type Parameters:
T
- the target type of deserialisation
- All Known Implementing Classes:
URLValueSerialiser
public interface ValueSerialiser<T>
Functional interface for serialising and deserialising configuration entries.
It should always be the case that if deserialisation succeeds, serialising the same value should succeed. That is,
It should always be the case that if deserialisation succeeds, serialising the same value should succeed. That is,
deserialise
and serialise
should be inverse operations.- Author:
- A248
-
Method Summary
Modifier and TypeMethodDescriptiondeserialise(FlexibleType flexibleType)
Deserialises a value from a flexible type representing a raw config value.Gets the target type of deserialisationserialise(T value, Decomposer decomposer)
Serialises a value to a raw config value.
-
Method Details
-
getTargetClass
Gets the target type of deserialisation- Returns:
- the target class type
-
deserialise
Deserialises a value from a flexible type representing a raw config value.
The key (FlexibleType.getAssociatedKey()
) is informative. It should not affect the deserialisation, but should be included in thrownBadValueException
s to inform the user which key is in question.- Parameters:
flexibleType
- the flexible type- Returns:
- the deserialised value, never
null
- Throws:
BadValueException
- if the value could not be deserialised
-
serialise
Serialises 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 deserialised.
If this serialiser serialises values by converting from another custom type, then the provideddecomposer
should be used to reserialise such custom types.- Parameters:
value
- the valuedecomposer
- the decomposer used to help breakdown the value- Returns:
- the serialised value
-