Package com.google.gson.internal.bind
Class JsonAdapterAnnotationTypeAdapterFactory
java.lang.Object
com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory
- All Implemented Interfaces:
TypeAdapterFactory
public final class JsonAdapterAnnotationTypeAdapterFactory
extends Object
implements TypeAdapterFactory
Given a type T, looks for the annotation
JsonAdapter
and uses an instance of the
specified class as the default type adapter.- Since:
- 2.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap
<Class<?>, TypeAdapterFactory> For a class, if it is annotated with@JsonAdapter
and refers to aTypeAdapterFactory
, stores the factory instance in case it has been requested already.private final ConstructorConstructor
private static final TypeAdapterFactory
Factory used forTreeTypeAdapter
s created for@JsonAdapter
on a class.private static final TypeAdapterFactory
Factory used forTreeTypeAdapter
s created for@JsonAdapter
on a field. -
Constructor Summary
ConstructorsConstructorDescriptionJsonAdapterAnnotationTypeAdapterFactory
(ConstructorConstructor constructorConstructor) -
Method Summary
Modifier and TypeMethodDescription<T> TypeAdapter
<T> Returns a type adapter fortype
, or null if this factory doesn't supporttype
.private static Object
createAdapter
(ConstructorConstructor constructorConstructor, Class<?> adapterClass) private static JsonAdapter
getAnnotation
(Class<?> rawType) (package private) TypeAdapter
<?> getTypeAdapter
(ConstructorConstructor constructorConstructor, Gson gson, TypeToken<?> type, JsonAdapter annotation, boolean isClassAnnotation) boolean
isClassJsonAdapterFactory
(TypeToken<?> type, TypeAdapterFactory factory) Returns whetherfactory
is a type adapter factory created for@JsonAdapter
placed ontype
.private TypeAdapterFactory
putFactoryAndGetCurrent
(Class<?> rawType, TypeAdapterFactory factory)
-
Field Details
-
TREE_TYPE_CLASS_DUMMY_FACTORY
Factory used forTreeTypeAdapter
s created for@JsonAdapter
on a class. -
TREE_TYPE_FIELD_DUMMY_FACTORY
Factory used forTreeTypeAdapter
s created for@JsonAdapter
on a field. -
constructorConstructor
-
adapterFactoryMap
For a class, if it is annotated with@JsonAdapter
and refers to aTypeAdapterFactory
, stores the factory instance in case it has been requested already. Has to be aConcurrentMap
becauseGson
guarantees to be thread-safe.
-
-
Constructor Details
-
JsonAdapterAnnotationTypeAdapterFactory
-
-
Method Details
-
getAnnotation
-
create
Description copied from interface:TypeAdapterFactory
Returns a type adapter fortype
, or null if this factory doesn't supporttype
.- Specified by:
create
in interfaceTypeAdapterFactory
-
createAdapter
private static Object createAdapter(ConstructorConstructor constructorConstructor, Class<?> adapterClass) -
putFactoryAndGetCurrent
-
getTypeAdapter
TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson, TypeToken<?> type, JsonAdapter annotation, boolean isClassAnnotation) -
isClassJsonAdapterFactory
Returns whetherfactory
is a type adapter factory created for@JsonAdapter
placed ontype
.
-