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 Details

    • of

      public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType, String typeFieldName, boolean maintainType)
      Creates a new runtime type adapter using for baseType using typeFieldName as the type field name. Type field names are case sensitive. maintainType flag decide if the type will be stored in pojo or not.
    • of

      public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType, String typeFieldName)
      Creates a new runtime type adapter using for baseType using typeFieldName as the type field name. Type field names are case sensitive.
    • of

      public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType)
      Creates a new runtime type adapter for baseType using "type" as the type field name.
    • registerSubtype

      public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type, String label)
      Registers type identified by label. Labels are case sensitive.
      Throws:
      IllegalArgumentException - if either type or label have already been registered on this type adapter.
    • registerSubtype

      public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type)
      Registers type identified by its simple name. Labels are case sensitive.
      Throws:
      IllegalArgumentException - if either type or 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:
      create in interface com.google.gson.TypeAdapterFactory