Class RpcTypeAdapterFactory

  • All Implemented Interfaces:
    com.google.gson.TypeAdapterFactory

    public final class RpcTypeAdapterFactory
    extends Object
    implements com.google.gson.TypeAdapterFactory
    Gson TypeAdapterFactory for IdTypeAdapter and ParameterTypeAdapter.
    Since:
    0.1.0
    Author:
    Elias*
    • Method Detail

      • instance

        public static RpcTypeAdapterFactory instance()
        Getter for singleton instance.

        The instance is lazyly instanciated, which means the the singleton instance is created when this method is invoked for the first time. Any consecutive calls return the instance.

        Returns:
        The only instance of RpcTypeAdapterFactory
      • create

        public <T> com.google.gson.TypeAdapter<T> create​(com.google.gson.Gson gson,
                                                         com.google.gson.reflect.TypeToken<T> type)
        Returns a TypeAdapter based on the following rules:

        The IdTypeAdapter singleton instance if the type implements Id.

        The ParameterTypeAdapter singleton instance if the type implements Parameters.

        Specified by:
        create in interface com.google.gson.TypeAdapterFactory
        Type Parameters:
        T - The type for which a TypeAdapter is needed
        Parameters:
        gson - The Gson instance to which this adapter is registered
        type - A TypeToken which specifies the type the TypeAdapter should handle
        Returns:
        A TypeAdapter which is either a IdTypeAdapter, ParameterTypeAdapter or null