Class JacksonJsonObjectReader<T>
- java.lang.Object
- org.springframework.batch.item.json.JacksonJsonObjectReader<T>
- Type Parameters:
T
- type of the target object
- All Implemented Interfaces:
JsonObjectReader<T>
public class JacksonJsonObjectReader<T> extends java.lang.Object implements JsonObjectReader<T>
Implementation ofJsonObjectReader
based on Jackson.- Since:
- 4.1
- Author:
- Mahmoud Ben Hassine
Constructor Summary
Constructors Constructor Description JacksonJsonObjectReader(java.lang.Class<? extends T> itemType)
Create a newJacksonJsonObjectReader
instance.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.fasterxml.jackson.databind.ObjectMapper mapper)
Set the object mapper to use to map Json objects to domain objects.
Constructor Detail
JacksonJsonObjectReader
public JacksonJsonObjectReader(java.lang.Class<? extends T> itemType)
Create a newJacksonJsonObjectReader
instance.- Parameters:
itemType
- the target item type
Method Detail
setMapper
public void setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
Set the object mapper to use to map Json objects to domain objects.- Parameters:
mapper
- the object mapper to use
open
public void open(org.springframework.core.io.Resource resource) throws java.lang.Exception
Description copied from interface:JsonObjectReader
Open the Json resource for reading.- Specified by:
open
in interfaceJsonObjectReader<T>
- Parameters:
resource
- the input resource- Throws:
java.lang.Exception
- if unable to open the resource
read
public T read() throws java.lang.Exception
Description copied from interface:JsonObjectReader
Read the next object in the Json resource if any.- Specified by:
read
in interfaceJsonObjectReader<T>
- Returns:
- the next object or
null
if the resource is exhausted - Throws:
java.lang.Exception
- if unable to read the next object
close
public void close() throws java.lang.Exception
Description copied from interface:JsonObjectReader
Close the input resource.- Specified by:
close
in interfaceJsonObjectReader<T>
- Throws:
java.lang.Exception
- if unable to close the input resource