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 implementConfigurationSerializable
, or be one ofInteger
,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 TypeMethodDescriptiondeserialize
(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.Converts a live value to its serialized form.
-
Method Details
-
serialize
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
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 typeSERIALIZED
- the Serialized type- Parameters:
serializer
- the serialization functiondeserializer
- the deserialization function- Returns:
- a new Codec
-