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@JsonAdapterand refers to aTypeAdapterFactory, stores the factory instance in case it has been requested already.private final ConstructorConstructorprivate static final TypeAdapterFactoryFactory used forTreeTypeAdapters created for@JsonAdapteron a class.private static final TypeAdapterFactoryFactory used forTreeTypeAdapters created for@JsonAdapteron 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 ObjectcreateAdapter(ConstructorConstructor constructorConstructor, Class<?> adapterClass) private static JsonAdaptergetAnnotation(Class<?> rawType) (package private) TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson, TypeToken<?> type, JsonAdapter annotation, boolean isClassAnnotation) booleanisClassJsonAdapterFactory(TypeToken<?> type, TypeAdapterFactory factory) Returns whetherfactoryis a type adapter factory created for@JsonAdapterplaced ontype.private TypeAdapterFactoryputFactoryAndGetCurrent(Class<?> rawType, TypeAdapterFactory factory)
-
Field Details
-
TREE_TYPE_CLASS_DUMMY_FACTORY
Factory used forTreeTypeAdapters created for@JsonAdapteron a class. -
TREE_TYPE_FIELD_DUMMY_FACTORY
Factory used forTreeTypeAdapters created for@JsonAdapteron a field. -
constructorConstructor
-
adapterFactoryMap
For a class, if it is annotated with@JsonAdapterand refers to aTypeAdapterFactory, stores the factory instance in case it has been requested already. Has to be aConcurrentMapbecauseGsonguarantees to be thread-safe.
-
-
Constructor Details
-
JsonAdapterAnnotationTypeAdapterFactory
-
-
Method Details
-
getAnnotation
-
create
Description copied from interface:TypeAdapterFactoryReturns a type adapter fortype, or null if this factory doesn't supporttype.- Specified by:
createin 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 whetherfactoryis a type adapter factory created for@JsonAdapterplaced ontype.
-