Interface Codec<LIVE,SERIALIZED>

Type Parameters:
LIVE - the type of the object as it's used within the plugin, should be matched by the ParameterType this codec is registered with.
SERIALIZED - the type of the object in its serialized form. This type must either implement ConfigurationSerializable, or be one of Integer, Double, Boolean, String, List, Set, Map.

public interface Codec<LIVE,SERIALIZED>
A converter that converts objects from their live form to their serialized form and vice versa. When a codec is registered, the ParameterType should match the LIVE type of this Codec.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    deserialize(SERIALIZED serializedValue)
    Converts a serialized value back into its live form.
    static <LIVE, SERIALIZED>
    Codec<LIVE,SERIALIZED>
    of(Function<? super LIVE,? extends SERIALIZED> serializer, Function<? super SERIALIZED,? extends LIVE> deserializer)
    Construct a codec from a serialization function and a deserialization function.
    serialize(LIVE liveValue)
    Converts a live value to its serialized form.
  • Method Details

    • serialize

      SERIALIZED serialize(LIVE liveValue)
      Converts a live value to its serialized form.
      Parameters:
      liveValue - the live value
      Returns:
      an object that contains the same information in a different form
    • deserialize

      LIVE deserialize(SERIALIZED serializedValue)
      Converts a serialized value back into its live form.
      Parameters:
      serializedValue - the serialized value
      Returns:
      an object that contains the same information in a different form
    • of

      static <LIVE, SERIALIZED> Codec<LIVE,SERIALIZED> of(Function<? super LIVE,? extends SERIALIZED> serializer, Function<? super SERIALIZED,? extends LIVE> deserializer)
      Construct a codec from a serialization function and a deserialization function.
      Type Parameters:
      LIVE - the Live type
      SERIALIZED - the Serialized type
      Parameters:
      serializer - the serialization function
      deserializer - the deserialization function
      Returns:
      a new Codec