Package eliasstar.jsonrpc.gson
Class RpcTypeAdapterFactory
- java.lang.Object
-
- eliasstar.jsonrpc.gson.RpcTypeAdapterFactory
-
- All Implemented Interfaces:
com.google.gson.TypeAdapterFactory
public final class RpcTypeAdapterFactory extends Object implements com.google.gson.TypeAdapterFactory
GsonTypeAdapterFactoryforIdTypeAdapterandParameterTypeAdapter.- Since:
- 0.1.0
- Author:
- Elias*
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> com.google.gson.TypeAdapter<T>create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> type)Returns aTypeAdapterbased on the following rules:static RpcTypeAdapterFactoryinstance()Getter for singleton instance.
-
-
-
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 aTypeAdapterbased on the following rules:The
IdTypeAdaptersingleton instance if the type implementsId.The
ParameterTypeAdaptersingleton instance if the type implementsParameters.- Specified by:
createin interfacecom.google.gson.TypeAdapterFactory- Type Parameters:
T- The type for which aTypeAdapteris needed- Parameters:
gson- TheGsoninstance to which this adapter is registeredtype- ATypeTokenwhich specifies the type theTypeAdaptershould handle- Returns:
- A
TypeAdapterwhich is either aIdTypeAdapter,ParameterTypeAdapteror null
-
-