public class SpongeDataSerializer extends Object implements Serializer<org.spongepowered.api.data.DataSerializable>
SER_KEY, SER_VALUE
Constructor and Description |
---|
SpongeDataSerializer() |
Modifier and Type | Method and Description |
---|---|
org.spongepowered.api.data.DataSerializable |
deserialize(JsonElement json,
Type typeOfT,
JsonDeserializationContext context)
Gson invokes this call-back method during deserialization when it encounters
a field of the specified type.
|
JsonElement |
serialize(org.spongepowered.api.data.DataSerializable src,
Type typeOfSrc,
JsonSerializationContext context)
Gson invokes this call-back method during serialization when it encounters a
field of the specified type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
serialize
public org.spongepowered.api.data.DataSerializable deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
JsonDeserializer
In the implementation of this call-back method, you should consider invoking
JsonDeserializationContext.deserialize(JsonElement, Type)
method to
create objects for any non-trivial field of the returned object. However, you
should never invoke it on the the same type passing json
since that
will cause an infinite loop (Gson will call your call-back method again).
deserialize
in interface JsonDeserializer<org.spongepowered.api.data.DataSerializable>
json
- The Json data being deserializedtypeOfT
- The type of the Object to deserialize toT
JsonParseException
- if json is not in the expected format of
typeofT
public JsonElement serialize(org.spongepowered.api.data.DataSerializable src, Type typeOfSrc, JsonSerializationContext context)
JsonSerializer
In the implementation of this call-back method, you should consider invoking
JsonSerializationContext.serialize(Object, Type)
method to create
JsonElements for any non-trivial field of the src
object. However,
you should never invoke it on the src
object itself since that will
cause an infinite loop (Gson will call your call-back method again).
serialize
in interface JsonSerializer<org.spongepowered.api.data.DataSerializable>
src
- the object that needs to be converted to Json.typeOfSrc
- the actual type (fully genericized version) of the source
object.