T
- type of the target objectpublic class GsonJsonObjectReader<T> extends java.lang.Object implements JsonObjectReader<T>
JsonObjectReader
based on
Google Gson.Constructor and Description |
---|
GsonJsonObjectReader(java.lang.Class<? extends T> itemType)
Create a new
GsonJsonObjectReader instance. |
GsonJsonObjectReader(com.google.gson.Gson mapper,
java.lang.Class<? extends T> itemType) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the input resource.
|
void |
open(org.springframework.core.io.Resource resource)
Open the Json resource for reading.
|
T |
read()
Read the next object in the Json resource if any.
|
void |
setMapper(com.google.gson.Gson mapper)
Set the object mapper to use to map Json objects to domain objects.
|
public GsonJsonObjectReader(java.lang.Class<? extends T> itemType)
GsonJsonObjectReader
instance.itemType
- the target item typepublic GsonJsonObjectReader(com.google.gson.Gson mapper, java.lang.Class<? extends T> itemType)
public void setMapper(com.google.gson.Gson mapper)
mapper
- the object mapper to useGsonJsonObjectReader(Gson, Class)
public void open(org.springframework.core.io.Resource resource) throws java.lang.Exception
JsonObjectReader
open
in interface JsonObjectReader<T>
resource
- the input resourcejava.lang.Exception
- if unable to open the resource@Nullable public T read() throws java.lang.Exception
JsonObjectReader
read
in interface JsonObjectReader<T>
null
if the resource is exhaustedjava.lang.Exception
- if unable to read the next objectpublic void close() throws java.lang.Exception
JsonObjectReader
close
in interface JsonObjectReader<T>
java.lang.Exception
- if unable to close the input resource