public class TextConfigSerializer extends AbstractDataBuilder<Text> implements TypeSerializer<Text>
TypeSerializer
for Text
objects. Serialization
is handled by serializing the text to String with the
TextSerializers.JSON
serializer, loading the String into a
GsonConfigurationLoader
, and setting the value of the
ConfigurationNode
to the root node of the GsonConfigurationLoader.
Although JSON is used for serialization internally, this has no effect on
the actual configuration format the developer chooses to use.Constructor and Description |
---|
TextConfigSerializer()
Creates a new
TextConfigSerializer . |
Modifier and Type | Method and Description |
---|---|
protected Optional<Text> |
buildContent(DataView container)
Builds the currently
AbstractDataBuilder.supportedVersion variant of the intended
DataSerializable , such that all content upgrades have already
been handled by AbstractDataBuilder.build(DataView) . |
Text |
deserialize(TypeToken<?> type,
ConfigurationNode value) |
void |
serialize(TypeToken<?> type,
Text obj,
ConfigurationNode value) |
build
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
from, reset
public TextConfigSerializer()
TextConfigSerializer
. Normally this should not
need to be created more than once.public Text deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException
deserialize
in interface TypeSerializer<Text>
ObjectMappingException
public void serialize(TypeToken<?> type, Text obj, ConfigurationNode value) throws ObjectMappingException
serialize
in interface TypeSerializer<Text>
ObjectMappingException
protected Optional<Text> buildContent(DataView container) throws InvalidDataException
AbstractDataBuilder
AbstractDataBuilder.supportedVersion
variant of the intended
DataSerializable
, such that all content upgrades have already
been handled by AbstractDataBuilder.build(DataView)
. This otherwise follows the
same contract as DataBuilder.build(DataView)
.buildContent
in class AbstractDataBuilder<Text>
container
- The container with data to build fromInvalidDataException
- If there's issues of invalid data formats
or invalid data