- java.lang.Object
-
- com.google.gson.internal.bind.TreeTypeAdapter.GsonContextImpl
-
- All Implemented Interfaces:
JsonDeserializationContext,JsonSerializationContext
- Enclosing class:
- TreeTypeAdapter<T>
private final class TreeTypeAdapter.GsonContextImpl extends java.lang.Object implements JsonSerializationContext, JsonDeserializationContext
-
-
Constructor Summary
Constructors Modifier Constructor Description privateGsonContextImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Rdeserialize(JsonElement json, java.lang.reflect.Type typeOfT)Invokes default deserialization on the specified object.JsonElementserialize(java.lang.Object src)Invokes default serialization on the specified object.JsonElementserialize(java.lang.Object src, java.lang.reflect.Type typeOfSrc)Invokes default serialization on the specified object passing the specific type information.
-
-
-
Method Detail
-
serialize
public JsonElement serialize(java.lang.Object src)
Description copied from interface:JsonSerializationContextInvokes default serialization on the specified object.- Specified by:
serializein interfaceJsonSerializationContext- Parameters:
src- the object that needs to be serialized.- Returns:
- a tree of
JsonElements corresponding to the serialized form ofsrc.
-
serialize
public JsonElement serialize(java.lang.Object src, java.lang.reflect.Type typeOfSrc)
Description copied from interface:JsonSerializationContextInvokes default serialization on the specified object passing the specific type information. It should never be invoked on the element received as a parameter of theJsonSerializer.serialize(Object, Type, JsonSerializationContext)method. Doing so will result in an infinite loop since Gson will in-turn call the custom serializer again.- Specified by:
serializein interfaceJsonSerializationContext- Parameters:
src- the object that needs to be serialized.typeOfSrc- the actual genericized type of src object.- Returns:
- a tree of
JsonElements corresponding to the serialized form ofsrc.
-
deserialize
public <R> R deserialize(JsonElement json, java.lang.reflect.Type typeOfT) throws JsonParseException
Description copied from interface:JsonDeserializationContextInvokes default deserialization on the specified object. It should never be invoked on the element received as a parameter of theJsonDeserializer.deserialize(JsonElement, Type, JsonDeserializationContext)method. Doing so will result in an infinite loop since Gson will in-turn call the custom deserializer again.- Specified by:
deserializein interfaceJsonDeserializationContext- Type Parameters:
R- The type of the deserialized object.- Parameters:
json- the parse tree.typeOfT- type of the expected return value.- Returns:
- An object of type typeOfT.
- Throws:
JsonParseException- if the parse tree does not contain expected data.
-
-