Package clarifai2.internal
Class JSONAdapterFactory<T>
- java.lang.Object
-
- clarifai2.internal.JSONAdapterFactory<T>
-
- Type Parameters:
T
- the type of data that will be serialized and/or deserialized
- All Implemented Interfaces:
com.google.gson.TypeAdapterFactory
public abstract class JSONAdapterFactory<T> extends java.lang.Object implements com.google.gson.TypeAdapterFactory
A type-safeTypeAdapterFactory
. This is preferable to using just a simpleTypeAdapter
because you can access the underlyingGson
instance, so nested objects can be handled by other adapters that are registered wit that Gson instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
JSONAdapterFactory.Deserializer<T>
An interface that defines how to convert a given JSON element to an object.protected static interface
JSONAdapterFactory.Serializer<T>
An interface that defines how to convert a given object to JSON.
-
Constructor Summary
Constructors Constructor Description JSONAdapterFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T1> com.google.gson.TypeAdapter<T1>
create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T1> typeToken)
protected @Nullable JSONAdapterFactory.Deserializer<T>
deserializer()
protected @Nullable JSONAdapterFactory.Serializer<T>
serializer()
protected abstract @NotNull com.google.gson.reflect.TypeToken<T>
typeToken()
-
-
-
Method Detail
-
serializer
@Nullable protected @Nullable JSONAdapterFactory.Serializer<T> serializer()
- Returns:
- a
JSONAdapterFactory.Serializer
that defines how to convert this object to a JSON representation, ornull
if this factory doesn't want to define how to perform this serialization.
-
deserializer
@Nullable protected @Nullable JSONAdapterFactory.Deserializer<T> deserializer()
- Returns:
- a
JSONAdapterFactory.Deserializer
that defines how to reify this object from a JSON representation, ornull
if this factory doesn't want to define how to perform this deserialization.
-
typeToken
@NotNull protected abstract @NotNull com.google.gson.reflect.TypeToken<T> typeToken()
-
create
public final <T1> com.google.gson.TypeAdapter<T1> create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T1> typeToken)
- Specified by:
create
in interfacecom.google.gson.TypeAdapterFactory
-
-