Package com.google.gson.graph
Class GraphAdapterBuilder.Factory
- java.lang.Object
-
- com.google.gson.graph.GraphAdapterBuilder.Factory
-
- All Implemented Interfaces:
InstanceCreator
,TypeAdapterFactory
- Enclosing class:
- GraphAdapterBuilder
static class GraphAdapterBuilder.Factory extends java.lang.Object implements TypeAdapterFactory, InstanceCreator
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ThreadLocal<GraphAdapterBuilder.Graph>
graphThreadLocal
private java.util.Map<java.lang.reflect.Type,InstanceCreator<?>>
instanceCreators
-
Constructor Summary
Constructors Constructor Description Factory(java.util.Map<java.lang.reflect.Type,InstanceCreator<?>> instanceCreators)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TypeAdapter<T>
create(Gson gson, TypeToken<T> type)
Returns a type adapter fortype
, or null if this factory doesn't supporttype
.java.lang.Object
createInstance(java.lang.reflect.Type type)
Hook for the graph adapter to get a reference to a deserialized value before that value is fully populated.
-
-
-
Field Detail
-
instanceCreators
private final java.util.Map<java.lang.reflect.Type,InstanceCreator<?>> instanceCreators
-
graphThreadLocal
private final java.lang.ThreadLocal<GraphAdapterBuilder.Graph> graphThreadLocal
-
-
Constructor Detail
-
Factory
Factory(java.util.Map<java.lang.reflect.Type,InstanceCreator<?>> instanceCreators)
-
-
Method Detail
-
create
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)
Description copied from interface:TypeAdapterFactory
Returns a type adapter fortype
, or null if this factory doesn't supporttype
.- Specified by:
create
in interfaceTypeAdapterFactory
-
createInstance
public java.lang.Object createInstance(java.lang.reflect.Type type)
Hook for the graph adapter to get a reference to a deserialized value before that value is fully populated. This is useful to deserialize values that directly or indirectly reference themselves: we can hand out an instance before read() returns.Gson should only ever call this method when we're expecting it to; that is only when we've called back into Gson to deserialize a tree.
- Specified by:
createInstance
in interfaceInstanceCreator
- Parameters:
type
- the parameterized T represented as aType
.- Returns:
- a default object instance of type T.
-
-