- 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 private
GsonContextImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> R
deserialize(JsonElement json, java.lang.reflect.Type typeOfT)
Invokes default deserialization on the specified object.JsonElement
serialize(java.lang.Object src)
Invokes default serialization on the specified object.JsonElement
serialize(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:JsonSerializationContext
Invokes default serialization on the specified object.- Specified by:
serialize
in interfaceJsonSerializationContext
- Parameters:
src
- the object that needs to be serialized.- Returns:
- a tree of
JsonElement
s corresponding to the serialized form ofsrc
.
-
serialize
public JsonElement serialize(java.lang.Object src, java.lang.reflect.Type typeOfSrc)
Description copied from interface:JsonSerializationContext
Invokes 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:
serialize
in interfaceJsonSerializationContext
- Parameters:
src
- the object that needs to be serialized.typeOfSrc
- the actual genericized type of src object.- Returns:
- a tree of
JsonElement
s corresponding to the serialized form ofsrc
.
-
deserialize
public <R> R deserialize(JsonElement json, java.lang.reflect.Type typeOfT) throws JsonParseException
Description copied from interface:JsonDeserializationContext
Invokes 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:
deserialize
in 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.
-
-