Package eliasstar.gson
Class OptionalTypeAdapterFactory
- java.lang.Object
-
- eliasstar.gson.OptionalTypeAdapterFactory
-
- All Implemented Interfaces:
com.google.gson.TypeAdapterFactory
public final class OptionalTypeAdapterFactory extends Object implements com.google.gson.TypeAdapterFactory
GsonTypeAdapterFactory
forOptionalTypeAdapter
.Creates a
OptionalTypeAdapter
instance for each Optional parameter type.- 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)
static OptionalTypeAdapterFactory
instance()
Getter for singleton instance.
-
-
-
Method Detail
-
instance
public static OptionalTypeAdapterFactory 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
OptionalTypeAdapterFactory
-
create
public <T> com.google.gson.TypeAdapter<T> create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> type)
- Specified by:
create
in interfacecom.google.gson.TypeAdapterFactory
- Type Parameters:
T
- The type for which aTypeAdapter
is needed- Parameters:
gson
- TheGson
instance to which this adapter is registeredtype
- ATypeToken
which specifies the type theTypeAdapter
should handle- Returns:
- A
TypeAdapter
which is either aOptionalTypeAdapter
or null
-
-