Class RuntimeTypeAdapterFactory<T>
java.lang.Object
cmpt213.assignment4.packagedeliveries.client.control.RuntimeTypeAdapterFactory<T>
- All Implemented Interfaces:
com.google.gson.TypeAdapterFactory
public final class RuntimeTypeAdapterFactory<T>
extends Object
implements com.google.gson.TypeAdapterFactory
-
Method Summary
Modifier and TypeMethodDescription<R> com.google.gson.TypeAdapter<R>create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<R> type) static <T> RuntimeTypeAdapterFactory<T>Creates a new runtime type adapter forbaseTypeusing"type"as the type field name.static <T> RuntimeTypeAdapterFactory<T>Creates a new runtime type adapter using forbaseTypeusingtypeFieldNameas the type field name.static <T> RuntimeTypeAdapterFactory<T>Creates a new runtime type adapter using forbaseTypeusingtypeFieldNameas the type field name.registerSubtype(Class<? extends T> type) Registerstypeidentified by itssimple name.registerSubtype(Class<? extends T> type, String label) Registerstypeidentified bylabel.
-
Method Details
-
of
public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType, String typeFieldName, boolean maintainType) Creates a new runtime type adapter using forbaseTypeusingtypeFieldNameas the type field name. Type field names are case sensitive.maintainTypeflag decide if the type will be stored in pojo or not. -
of
Creates a new runtime type adapter using forbaseTypeusingtypeFieldNameas the type field name. Type field names are case sensitive. -
of
Creates a new runtime type adapter forbaseTypeusing"type"as the type field name. -
registerSubtype
Registerstypeidentified bylabel. Labels are case sensitive.- Throws:
IllegalArgumentException- if eithertypeorlabelhave already been registered on this type adapter.
-
registerSubtype
Registerstypeidentified by itssimple name. Labels are case sensitive.- Throws:
IllegalArgumentException- if eithertypeor its simple name have already been registered on this type adapter.
-
create
public <R> com.google.gson.TypeAdapter<R> create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<R> type) - Specified by:
createin interfacecom.google.gson.TypeAdapterFactory
-