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, deserialise and serialise should be inverse operations.
Author:
A248
  • Method Summary

    Modifier and Type
    Method
    Description
    deserialise(FlexibleType flexibleType)
    Deserializes a value from a flexible type representing a raw config value.
    Gets the target type of deserialization
    serialise(T value, Decomposer decomposer)
    Serializes a value to a raw config value.
  • Method Details

    • getTargetClass

      Class<T> getTargetClass()
      Gets the target type of deserialization
      Returns:
      the target class type
    • deserialise

      T deserialise(FlexibleType flexibleType) throws BadValueException
      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 thrown BadValueExceptions to inform the user which key is in question. To easily include the key in a BadValueException, use FlexibleType.badValueExceptionBuilder()
      Parameters:
      flexibleType - the flexible type
      Returns:
      the deserialized value, never null
      Throws:
      BadValueException - if the value could not be deserialized
    • serialise

      Object serialise(T value, Decomposer decomposer)
      Serializes a value to a raw config value. Should be the inverse operation of deserialise(FlexibleType) in that if the result of this method were wrapped in a FlexibleType, it could be deserialized.

      If this serializer serializes values by converting from another custom type, then the provided decomposer should be used to reserialize such custom types.
      Parameters:
      value - the value
      decomposer - the decomposer used to help breakdown the value
      Returns:
      the serialized value